diff options
author | Stas Vilchik <stas.vilchik@sonarsource.com> | 2017-11-24 17:15:30 +0100 |
---|---|---|
committer | Stas Vilchik <stas.vilchik@sonarsource.com> | 2017-11-24 19:08:33 +0100 |
commit | cf0f94223f4466e53c04bd74861f3432c67d33dd (patch) | |
tree | f5c3eb87afbc5287497d8515e825ca8b54c227df /server/sonar-web/src/main/js | |
parent | edca759a8b0943013c12871477aa82d5e9ddfef8 (diff) | |
download | sonarqube-cf0f94223f4466e53c04bd74861f3432c67d33dd.tar.gz sonarqube-cf0f94223f4466e53c04bd74861f3432c67d33dd.zip |
fix assignee select in bulk change form
Diffstat (limited to 'server/sonar-web/src/main/js')
3 files changed, 7 insertions, 9 deletions
diff --git a/server/sonar-web/src/main/js/apps/issues/components/BulkChangeModal.js b/server/sonar-web/src/main/js/apps/issues/components/BulkChangeModal.js index be83b1df340..f5b15d1aac8 100644 --- a/server/sonar-web/src/main/js/apps/issues/components/BulkChangeModal.js +++ b/server/sonar-web/src/main/js/apps/issues/components/BulkChangeModal.js @@ -295,7 +295,7 @@ export default class BulkChangeModal extends React.PureComponent { <SearchSelect onSearch={this.handleAssigneeSearch} onSelect={this.handleAssigneeSelect} - minimumQueryLength={0} + minimumQueryLength={2} renderOption={this.renderAssigneeOption} resetOnBlur={false} value={this.state.assignee} diff --git a/server/sonar-web/src/main/js/components/controls/SearchSelect.js b/server/sonar-web/src/main/js/components/controls/SearchSelect.js index 0fbe8ff9f58..0a43d0992e4 100644 --- a/server/sonar-web/src/main/js/components/controls/SearchSelect.js +++ b/server/sonar-web/src/main/js/components/controls/SearchSelect.js @@ -87,19 +87,17 @@ export default class SearchSelect extends React.PureComponent { ); }; - handleBlur = () => { - this.setState({ options: [], query: '' }); - }; - handleChange = (option /*: Option */) => { this.props.onSelect(option.value); }; - handleInputChange = (query /*: string */ = '') => { + handleInputChange = (query /*: string */) => { + // `onInputChange` is called with an empty string after a user selects a value + // in this case we shouldn't reset `options`, because it also resets select value :( if (query.length >= this.props.minimumQueryLength) { this.setState({ loading: true, query }); this.search(query); - } else { + } else if (query.length > 0) { this.setState({ options: [], query }); } }; @@ -121,7 +119,7 @@ export default class SearchSelect extends React.PureComponent { ? translateWithParameters('select2.tooShort', this.props.minimumQueryLength) : translate('select2.noMatches') } - onBlur={this.props.resetOnBlur ? this.handleBlur : undefined} + onBlurResetsInput={this.props.resetOnBlur} onChange={this.handleChange} onInputChange={this.handleInputChange} onOpen={this.props.minimumQueryLength === 0 ? this.handleInputChange : undefined} diff --git a/server/sonar-web/src/main/js/components/controls/__tests__/__snapshots__/SearchSelect-test.js.snap b/server/sonar-web/src/main/js/components/controls/__tests__/__snapshots__/SearchSelect-test.js.snap index 0aae3eb7466..00b34224f8c 100644 --- a/server/sonar-web/src/main/js/components/controls/__tests__/__snapshots__/SearchSelect-test.js.snap +++ b/server/sonar-web/src/main/js/components/controls/__tests__/__snapshots__/SearchSelect-test.js.snap @@ -9,7 +9,7 @@ exports[`should render Select 1`] = ` filterOption={[Function]} isLoading={false} noResultsText="select2.tooShort.2" - onBlur={[Function]} + onBlurResetsInput={true} onChange={[Function]} onInputChange={[Function]} options={Array []} |