Commit fe94e97
fix: Allow space character in Select input (#1210)
* 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.
* 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.
* chore: add comment explaining preventDefault behavior for Space key
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* 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>
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>1 parent 8327910 commit fe94e97
2 files changed
+63
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
471 | 471 | | |
472 | 472 | | |
473 | 473 | | |
474 | | - | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
475 | 477 | | |
476 | 478 | | |
477 | 479 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2985 | 2985 | | |
2986 | 2986 | | |
2987 | 2987 | | |
| 2988 | + | |
| 2989 | + | |
| 2990 | + | |
| 2991 | + | |
| 2992 | + | |
| 2993 | + | |
| 2994 | + | |
| 2995 | + | |
| 2996 | + | |
| 2997 | + | |
| 2998 | + | |
| 2999 | + | |
| 3000 | + | |
| 3001 | + | |
| 3002 | + | |
| 3003 | + | |
| 3004 | + | |
| 3005 | + | |
| 3006 | + | |
| 3007 | + | |
| 3008 | + | |
| 3009 | + | |
| 3010 | + | |
| 3011 | + | |
| 3012 | + | |
| 3013 | + | |
| 3014 | + | |
| 3015 | + | |
| 3016 | + | |
| 3017 | + | |
| 3018 | + | |
| 3019 | + | |
| 3020 | + | |
| 3021 | + | |
| 3022 | + | |
| 3023 | + | |
| 3024 | + | |
| 3025 | + | |
| 3026 | + | |
| 3027 | + | |
| 3028 | + | |
| 3029 | + | |
| 3030 | + | |
| 3031 | + | |
| 3032 | + | |
| 3033 | + | |
| 3034 | + | |
| 3035 | + | |
| 3036 | + | |
| 3037 | + | |
| 3038 | + | |
| 3039 | + | |
| 3040 | + | |
| 3041 | + | |
| 3042 | + | |
| 3043 | + | |
| 3044 | + | |
| 3045 | + | |
| 3046 | + | |
| 3047 | + | |
2988 | 3048 | | |
0 commit comments