From cf0f94223f4466e53c04bd74861f3432c67d33dd Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Fri, 24 Nov 2017 17:15:30 +0100 Subject: [PATCH] fix assignee select in bulk change form --- .../js/apps/issues/components/BulkChangeModal.js | 2 +- .../src/main/js/components/controls/SearchSelect.js | 12 +++++------- .../__snapshots__/SearchSelect-test.js.snap | 2 +- 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 { { - 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 []} -- 2.39.5