Skip to content

Commit 70ee949

Browse files
zombieJclaude
andcommitted
refactor: refine enter/space key preventDefault logic
Separate isCombobox check and apply different preventDefault logic: - Space: prevent only when not editable - Enter: prevent only when not combobox Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent f6401ce commit 70ee949

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/BaseSelect/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -471,8 +471,9 @@ const BaseSelect = React.forwardRef<BaseSelectRef, BaseSelectProps>((props, ref)
471471
// Enter or Space opens dropdown (ARIA combobox: spacebar should open)
472472
if (isEnterKey || isSpaceKey) {
473473
// Do not submit form when type in the input; prevent Space from scrolling page
474-
const isEditable = mode === 'combobox' || showSearch;
475-
if (!isEditable) {
474+
const isCombobox = mode === 'combobox';
475+
const isEditable = isCombobox || showSearch;
476+
if ((isSpaceKey && !isEditable) || (isEnterKey && !isCombobox)) {
476477
event.preventDefault();
477478
}
478479

0 commit comments

Comments
 (0)