diff --git a/packages/terra-form-select/CHANGELOG.md b/packages/terra-form-select/CHANGELOG.md index 59de6686d7e..400df7d4914 100644 --- a/packages/terra-form-select/CHANGELOG.md +++ b/packages/terra-form-select/CHANGELOG.md @@ -2,12 +2,14 @@ ## Unreleased +* Fixed + * Search field value now persists when navigating to another component. + ## 6.62.1 - (May 13, 2024) * Fixed * Fixed a "prop not recognized" console error. - ## 6.62.0 - (May 8, 2024) * Added diff --git a/packages/terra-form-select/src/search/Frame.jsx b/packages/terra-form-select/src/search/Frame.jsx index 3de7fb13ea9..2cc7f37b49a 100644 --- a/packages/terra-form-select/src/search/Frame.jsx +++ b/packages/terra-form-select/src/search/Frame.jsx @@ -232,10 +232,9 @@ class Frame extends React.Component { this.setState({ isFocused: false, focusedByTouch: false }); if (this.state.hasSearchChanged) { - this.setState({ - searchValue: this.props.display, - hasSearchChanged: false, - }); + this.setState((prevState) => ({ + searchValue: prevState.searchValue.trim(), + })); } this.closeDropdown(); diff --git a/packages/terra-form-select/tests/wdio/__snapshots__/reference/clinical-lowlight-theme/en/chrome_tiny/select-spec/search_open_dropdown_by_down_arrow.png b/packages/terra-form-select/tests/wdio/__snapshots__/reference/clinical-lowlight-theme/en/chrome_tiny/select-spec/search_open_dropdown_by_down_arrow.png index 04a9a2effb9..d40c6c58e6a 100644 Binary files a/packages/terra-form-select/tests/wdio/__snapshots__/reference/clinical-lowlight-theme/en/chrome_tiny/select-spec/search_open_dropdown_by_down_arrow.png and b/packages/terra-form-select/tests/wdio/__snapshots__/reference/clinical-lowlight-theme/en/chrome_tiny/select-spec/search_open_dropdown_by_down_arrow.png differ diff --git a/packages/terra-form-select/tests/wdio/__snapshots__/reference/clinical-lowlight-theme/en/chrome_tiny/select-spec/search_opened-dropdown.png b/packages/terra-form-select/tests/wdio/__snapshots__/reference/clinical-lowlight-theme/en/chrome_tiny/select-spec/search_opened-dropdown.png index ed2dbff6e4a..1cc0faa5797 100644 Binary files a/packages/terra-form-select/tests/wdio/__snapshots__/reference/clinical-lowlight-theme/en/chrome_tiny/select-spec/search_opened-dropdown.png and b/packages/terra-form-select/tests/wdio/__snapshots__/reference/clinical-lowlight-theme/en/chrome_tiny/select-spec/search_opened-dropdown.png differ diff --git a/packages/terra-form-select/tests/wdio/__snapshots__/reference/clinical-lowlight-theme/en/chrome_tiny/select-spec/search_toggle-opened-dropdown.png b/packages/terra-form-select/tests/wdio/__snapshots__/reference/clinical-lowlight-theme/en/chrome_tiny/select-spec/search_toggle-opened-dropdown.png index 81008d274b3..7b19a93e3ba 100644 Binary files a/packages/terra-form-select/tests/wdio/__snapshots__/reference/clinical-lowlight-theme/en/chrome_tiny/select-spec/search_toggle-opened-dropdown.png and b/packages/terra-form-select/tests/wdio/__snapshots__/reference/clinical-lowlight-theme/en/chrome_tiny/select-spec/search_toggle-opened-dropdown.png differ diff --git a/packages/terra-form-select/tests/wdio/__snapshots__/reference/orion-fusion-theme/en/chrome_tiny/select-spec/search_does_not_open_on_enter.png b/packages/terra-form-select/tests/wdio/__snapshots__/reference/orion-fusion-theme/en/chrome_tiny/select-spec/search_does_not_open_on_enter.png index 001c9383c43..71b53293cb0 100644 Binary files a/packages/terra-form-select/tests/wdio/__snapshots__/reference/orion-fusion-theme/en/chrome_tiny/select-spec/search_does_not_open_on_enter.png and b/packages/terra-form-select/tests/wdio/__snapshots__/reference/orion-fusion-theme/en/chrome_tiny/select-spec/search_does_not_open_on_enter.png differ diff --git a/packages/terra-form-select/tests/wdio/__snapshots__/reference/orion-fusion-theme/en/chrome_tiny/select-spec/search_open_dropdown_by_down_arrow.png b/packages/terra-form-select/tests/wdio/__snapshots__/reference/orion-fusion-theme/en/chrome_tiny/select-spec/search_open_dropdown_by_down_arrow.png index 80c3b124085..c0263e3c443 100644 Binary files a/packages/terra-form-select/tests/wdio/__snapshots__/reference/orion-fusion-theme/en/chrome_tiny/select-spec/search_open_dropdown_by_down_arrow.png and b/packages/terra-form-select/tests/wdio/__snapshots__/reference/orion-fusion-theme/en/chrome_tiny/select-spec/search_open_dropdown_by_down_arrow.png differ diff --git a/packages/terra-form-select/tests/wdio/__snapshots__/reference/orion-fusion-theme/en/chrome_tiny/select-spec/search_opened-dropdown.png b/packages/terra-form-select/tests/wdio/__snapshots__/reference/orion-fusion-theme/en/chrome_tiny/select-spec/search_opened-dropdown.png index 80c3b124085..c0263e3c443 100644 Binary files a/packages/terra-form-select/tests/wdio/__snapshots__/reference/orion-fusion-theme/en/chrome_tiny/select-spec/search_opened-dropdown.png and b/packages/terra-form-select/tests/wdio/__snapshots__/reference/orion-fusion-theme/en/chrome_tiny/select-spec/search_opened-dropdown.png differ diff --git a/packages/terra-form-select/tests/wdio/__snapshots__/reference/orion-fusion-theme/en/chrome_tiny/select-spec/search_toggle-opened-dropdown.png b/packages/terra-form-select/tests/wdio/__snapshots__/reference/orion-fusion-theme/en/chrome_tiny/select-spec/search_toggle-opened-dropdown.png index 80c3b124085..c0263e3c443 100644 Binary files a/packages/terra-form-select/tests/wdio/__snapshots__/reference/orion-fusion-theme/en/chrome_tiny/select-spec/search_toggle-opened-dropdown.png and b/packages/terra-form-select/tests/wdio/__snapshots__/reference/orion-fusion-theme/en/chrome_tiny/select-spec/search_toggle-opened-dropdown.png differ diff --git a/packages/terra-form-select/tests/wdio/__snapshots__/reference/terra-default-theme/en/chrome_tiny/select-spec/search_close_on_outside_click_after_toggle_open.png b/packages/terra-form-select/tests/wdio/__snapshots__/reference/terra-default-theme/en/chrome_tiny/select-spec/search_close_on_outside_click_after_toggle_open.png index 5e0c2473f42..f0b88b1c96c 100644 Binary files a/packages/terra-form-select/tests/wdio/__snapshots__/reference/terra-default-theme/en/chrome_tiny/select-spec/search_close_on_outside_click_after_toggle_open.png and b/packages/terra-form-select/tests/wdio/__snapshots__/reference/terra-default-theme/en/chrome_tiny/select-spec/search_close_on_outside_click_after_toggle_open.png differ diff --git a/packages/terra-form-select/tests/wdio/__snapshots__/reference/terra-default-theme/en/chrome_tiny/select-spec/search_closes_dropdown_after_clicking_off.png b/packages/terra-form-select/tests/wdio/__snapshots__/reference/terra-default-theme/en/chrome_tiny/select-spec/search_closes_dropdown_after_clicking_off.png index 5e0c2473f42..f0b88b1c96c 100644 Binary files a/packages/terra-form-select/tests/wdio/__snapshots__/reference/terra-default-theme/en/chrome_tiny/select-spec/search_closes_dropdown_after_clicking_off.png and b/packages/terra-form-select/tests/wdio/__snapshots__/reference/terra-default-theme/en/chrome_tiny/select-spec/search_closes_dropdown_after_clicking_off.png differ diff --git a/packages/terra-form-select/tests/wdio/__snapshots__/reference/terra-default-theme/en/chrome_tiny/select-spec/search_does_not_open_on_enter.png b/packages/terra-form-select/tests/wdio/__snapshots__/reference/terra-default-theme/en/chrome_tiny/select-spec/search_does_not_open_on_enter.png index 8af2390e385..c0231a2a5b1 100644 Binary files a/packages/terra-form-select/tests/wdio/__snapshots__/reference/terra-default-theme/en/chrome_tiny/select-spec/search_does_not_open_on_enter.png and b/packages/terra-form-select/tests/wdio/__snapshots__/reference/terra-default-theme/en/chrome_tiny/select-spec/search_does_not_open_on_enter.png differ diff --git a/packages/terra-form-select/tests/wdio/__snapshots__/reference/terra-default-theme/en/chrome_tiny/select-spec/search_open_dropdown_by_down_arrow.png b/packages/terra-form-select/tests/wdio/__snapshots__/reference/terra-default-theme/en/chrome_tiny/select-spec/search_open_dropdown_by_down_arrow.png index 41513e7b999..befe7158132 100644 Binary files a/packages/terra-form-select/tests/wdio/__snapshots__/reference/terra-default-theme/en/chrome_tiny/select-spec/search_open_dropdown_by_down_arrow.png and b/packages/terra-form-select/tests/wdio/__snapshots__/reference/terra-default-theme/en/chrome_tiny/select-spec/search_open_dropdown_by_down_arrow.png differ diff --git a/packages/terra-form-select/tests/wdio/__snapshots__/reference/terra-default-theme/en/chrome_tiny/select-spec/search_opened-dropdown.png b/packages/terra-form-select/tests/wdio/__snapshots__/reference/terra-default-theme/en/chrome_tiny/select-spec/search_opened-dropdown.png index 41513e7b999..befe7158132 100644 Binary files a/packages/terra-form-select/tests/wdio/__snapshots__/reference/terra-default-theme/en/chrome_tiny/select-spec/search_opened-dropdown.png and b/packages/terra-form-select/tests/wdio/__snapshots__/reference/terra-default-theme/en/chrome_tiny/select-spec/search_opened-dropdown.png differ diff --git a/packages/terra-form-select/tests/wdio/__snapshots__/reference/terra-default-theme/en/chrome_tiny/select-spec/search_toggle-opened-dropdown.png b/packages/terra-form-select/tests/wdio/__snapshots__/reference/terra-default-theme/en/chrome_tiny/select-spec/search_toggle-opened-dropdown.png index 41513e7b999..befe7158132 100644 Binary files a/packages/terra-form-select/tests/wdio/__snapshots__/reference/terra-default-theme/en/chrome_tiny/select-spec/search_toggle-opened-dropdown.png and b/packages/terra-form-select/tests/wdio/__snapshots__/reference/terra-default-theme/en/chrome_tiny/select-spec/search_toggle-opened-dropdown.png differ diff --git a/packages/terra-form-select/tests/wdio/select-spec.js b/packages/terra-form-select/tests/wdio/select-spec.js index 0f665b41628..530e5ed5648 100644 --- a/packages/terra-form-select/tests/wdio/select-spec.js +++ b/packages/terra-form-select/tests/wdio/select-spec.js @@ -1795,6 +1795,33 @@ Terra.describeViewports('Select', ['tiny'], () => { after(() => $('#root').click()); }); + + describe('should retain input value on fucusing another component', () => { + it('retain input and focus using tab key', () => { + $('[data-terra-select]').click(); + const input = $('[data-terra-select-combobox] input'); + input.setValue('Test'); + + // Pressing Tab key twice to focus the body + browser.keys('Tab'); + browser.keys('Tab'); + + expect($('body')).toBeFocused(); + expect(input).toHaveValue('Test'); + }); + + it('should retain input value and focus body when body is clicked', () => { + const input = $('[data-terra-select-combobox] input'); + + $('[data-terra-select]').click(); + input.setValue('Test'); + + $('body').click(); + + expect($('body')).toBeFocused(); + expect(input).toHaveValue('Test'); + }); + }); }); describe('Search Variant - controlled', () => {