Skip to content

Commit f566f35

Browse files
committed
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.
1 parent 8327910 commit f566f35

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/BaseSelect/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -470,8 +470,8 @@ const BaseSelect = React.forwardRef<BaseSelectRef, BaseSelectProps>((props, ref)
470470

471471
// Enter or Space opens dropdown (ARIA combobox: spacebar should open)
472472
if (isEnterKey || isSpaceKey) {
473-
// Do not submit form when type in the input; prevent Space from scrolling page
474-
if (mode !== 'combobox') {
473+
const isEditable = mode === 'combobox' || showSearch;
474+
if (!isEditable) {
475475
event.preventDefault();
476476
}
477477

0 commit comments

Comments
 (0)