diff --git a/src/SelectInput/Input.tsx b/src/SelectInput/Input.tsx index e69eace1..8c12606a 100644 --- a/src/SelectInput/Input.tsx +++ b/src/SelectInput/Input.tsx @@ -95,7 +95,13 @@ const Input = React.forwardRef((props, ref) => { const { value: nextVal } = event.currentTarget; // Handle Enter key submission - referencing Selector implementation - if (key === 'Enter' && mode === 'tags' && !compositionStatusRef.current && onSearchSubmit) { + if ( + key === 'Enter' && + mode === 'tags' && + !open && + !compositionStatusRef.current && + onSearchSubmit + ) { onSearchSubmit(nextVal); } diff --git a/tests/Tags.test.tsx b/tests/Tags.test.tsx index 99e3d295..74da8995 100644 --- a/tests/Tags.test.tsx +++ b/tests/Tags.test.tsx @@ -140,6 +140,29 @@ describe('Select.Tags', () => { expectOpen(container, false); }); + it('should trigger onSelect once when pressing Enter to select option in tags mode (dropdown open)', () => { + const handleSelect = jest.fn(); + const { container } = render( +