From f566f35a135436b5a33d1c07003d9416fa3f48e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8C=E8=B4=A7=E6=9C=BA=E5=99=A8=E4=BA=BA?= Date: Sat, 14 Feb 2026 13:19:16 +0800 Subject: [PATCH 1/4] Fix: Allow space character in Select input Fixed issue where pressing the space key in Select input would not add a space character to the input field. The root cause was that preventDefault() was always called when mode was not 'combobox', which prevented typing spaces even when the input was editable in showSearch mode. Changes: - Modified space key handling to only call preventDefault() when the input is not editable - Input is considered editable when mode is 'combobox' or showSearch is true - This allows users to type spaces in editable Select inputs while preventing default behavior (scroll/submit) in non-editable Selects This fix allows users to type spaces in search terms within Select components with showSearch enabled. --- src/BaseSelect/index.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/BaseSelect/index.tsx b/src/BaseSelect/index.tsx index 788ecd05..eeab4b1f 100644 --- a/src/BaseSelect/index.tsx +++ b/src/BaseSelect/index.tsx @@ -470,8 +470,8 @@ const BaseSelect = React.forwardRef((props, ref) // Enter or Space opens dropdown (ARIA combobox: spacebar should open) if (isEnterKey || isSpaceKey) { - // Do not submit form when type in the input; prevent Space from scrolling page - if (mode !== 'combobox') { + const isEditable = mode === 'combobox' || showSearch; + if (!isEditable) { event.preventDefault(); } From cfa1ff5eb95dc3ad0bec1bdbf2d51f1ee772b0aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8C=E8=B4=A7=E6=9C=BA=E5=99=A8=E4=BA=BA?= Date: Sat, 14 Feb 2026 13:29:04 +0800 Subject: [PATCH 2/4] Test: Add test cases for space key behavior with showSearch Added test coverage to verify space key behavior in different Select modes: 1. showSearch enabled: Space should NOT call preventDefault, allowing space to be typed 2. showSearch disabled: Space SHOULD call preventDefault, preventing page scroll 3. combobox mode: Space should NOT call preventDefault, allowing space to be typed These tests ensure the fix correctly handles space key input based on whether the input is editable. --- tests/Select.test.tsx | 60 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/tests/Select.test.tsx b/tests/Select.test.tsx index 46de7641..3cdf6128 100644 --- a/tests/Select.test.tsx +++ b/tests/Select.test.tsx @@ -2985,4 +2985,64 @@ describe('Select.Basic', () => { expect(selectedItem).not.toHaveAttribute('xxx'); }); + + describe('Space key behavior with showSearch', () => { + it('should not call preventDefault on space when showSearch is enabled', () => { + const { container } = render( + ); + + const input = container.querySelector('input'); + input.focus(); + + const keyDownEvent = new KeyboardEvent('keydown', { + key: ' ', + code: 'Space', + bubbles: true, + }); + const preventDefaultSpy = jest.spyOn(keyDownEvent, 'preventDefault'); + + input.dispatchEvent(keyDownEvent); + + expect(preventDefaultSpy).toHaveBeenCalled(); + }); + + it('should not call preventDefault on space in combobox mode', () => { + const { container } = render( +