File tree Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -889,13 +889,14 @@ export class ChComboBoxRender
889889 SELECTED_ITEM_SELECTOR
890890 ) as HTMLElement | undefined ;
891891
892- // Focus the selected element to force the scroll into view
892+ // Don't use focus, use scrollIntoView to avoid focus stealing and race
893+ // conditions
893894 if ( selectedElement ) {
894- // Wait until the JS has been executed to avoid race conditions when
895- // rendering elements in the top layer and trying to focus them
896- requestAnimationFrame ( ( ) => {
897- selectedElement . focus ( ) ;
898- this . #inputRef . focus ( ) ;
895+ selectedElement . scrollIntoView ( {
896+ block : "nearest" ,
897+ // @ts -expect-error This property is widely supported but not in the
898+ // lib.dom.ts
899+ container : "nearest"
899900 } ) ;
900901 }
901902 }
You can’t perform that action at this time.
0 commit comments