diff --git a/assets/js/base/components/combobox/index.tsx b/assets/js/base/components/combobox/index.tsx index 0f0adbec379..c29df06c5c4 100644 --- a/assets/js/base/components/combobox/index.tsx +++ b/assets/js/base/components/combobox/index.tsx @@ -34,7 +34,6 @@ export interface ComboboxProps { options: ComboboxControlOption[]; required?: boolean; value: string; - requireExactMatch?: boolean; } /** @@ -55,7 +54,6 @@ const Combobox = ( { errorId: incomingErrorId, instanceId = '0', autoComplete = 'off', - requireExactMatch = false, }: ComboboxProps ): JSX.Element => { const { getValidationError, @@ -138,13 +136,7 @@ const Combobox = ( { normalizedFilterValue ); if ( foundOption ) { - if ( ! requireExactMatch ) { - onChange( foundOption.value ); - return; - } - if ( foundOption.label === filterValue ) { - onChange( foundOption.value ); - } + onChange( foundOption.value ); } } } } diff --git a/assets/js/base/components/combobox/test/index.js b/assets/js/base/components/combobox/test/index.js deleted file mode 100644 index 9a65ebd3579..00000000000 --- a/assets/js/base/components/combobox/test/index.js +++ /dev/null @@ -1,56 +0,0 @@ -/** - * External dependencies - */ -import { render, screen } from '@testing-library/react'; -import userEvent from '@testing-library/user-event'; -import Combobox from '@woocommerce/base-components/combobox'; - -describe( 'ComboBox', () => { - const options = [ - { value: 'A', label: 'A value A' }, - { value: 'B', label: 'B value B' }, - { value: 'C', label: 'C value C' }, - { value: 'D', label: 'D value D' }, - { value: 'E', label: 'E value E' }, - { value: 'F', label: 'F value F' }, - ]; - - beforeEach( () => { - jest.resetAllMocks(); - } ); - - it( 'calls onChange as soon as a value is changed if requireExactMatch is false or undefined', async () => { - const onChange = jest.fn(); - const label = 'combo-box'; - render( - - ); - const input = await screen.findByLabelText( label ); - await userEvent.type( input, 'A ' ); - expect( onChange ).toHaveBeenCalledWith( 'A' ); - } ); - - it( 'calls onChange only when the value is equal to one of the options when requireExactMatch is true', async () => { - const onChange = jest.fn(); - const label = 'combo-box'; - render( - - ); - const input = await screen.findByLabelText( label ); - await userEvent.type( input, 'A ' ); - expect( onChange ).not.toHaveBeenCalled(); - await userEvent.type( input, 'value A' ); - expect( onChange ).toHaveBeenCalledWith( 'A' ); - } ); -} ); diff --git a/assets/js/base/components/country-input/country-input.tsx b/assets/js/base/components/country-input/country-input.tsx index 808a35d278e..7ef10861325 100644 --- a/assets/js/base/components/country-input/country-input.tsx +++ b/assets/js/base/components/country-input/country-input.tsx @@ -56,7 +56,6 @@ export const CountryInput = ( { errorMessage={ errorMessage } required={ required } autoComplete={ autoComplete } - requireExactMatch={ true } /> { autoComplete !== 'off' && ( { autoComplete !== 'off' && (