File tree Expand file tree Collapse file tree 2 files changed +16
-11
lines changed Expand file tree Collapse file tree 2 files changed +16
-11
lines changed Original file line number Diff line number Diff line change @@ -197,18 +197,22 @@ export default function SelectT<T>(props: SelectTProps<T>): JSX.Element {
197197 } ;
198198
199199 const onKeyDownHandler = ( e : KeyboardEvent < HTMLInputElement > ) => {
200- const pressedLetter = e . key . toUpperCase ( ) ;
201- const items = dropdownRef . current ?. getElementsByTagName ( 'li' ) ;
202- if ( items ) {
203- const arrayOfItems = Array . from ( items ) ;
204- for ( const item of arrayOfItems ) {
205- if ( item . dataset . key === pressedLetter ) {
206- item . scrollIntoView ( {
207- behavior : 'smooth' ,
208- block : 'start' ,
209- } ) ;
200+ if ( e . key === 'Tab' ) {
201+ toggleOptions ( ) ;
202+ } else {
203+ const pressedLetter = e . key . toUpperCase ( ) ;
204+ const items = dropdownRef . current ?. getElementsByTagName ( 'li' ) ;
205+ if ( items ) {
206+ const arrayOfItems = Array . from ( items ) ;
207+ for ( const item of arrayOfItems ) {
208+ if ( item . dataset . key === pressedLetter ) {
209+ item . scrollIntoView ( {
210+ behavior : 'smooth' ,
211+ block : 'start' ,
212+ } ) ;
210213
211- return ;
214+ return ;
215+ }
212216 }
213217 }
214218 }
Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ const EditableTemplate: Story<SelectProps> = (args) => {
3434 < Box height = '1000px' >
3535 < Box width = '200px' margin = '0 auto' >
3636 < Select { ...args } onChange = { handleChange } selectedValue = { value } options = { options } />
37+ < input />
3738 </ Box >
3839 </ Box >
3940 </ Box >
You can’t perform that action at this time.
0 commit comments