Skip to content

Commit

Permalink
fix(dropdown): Delay setting focus on first item to prevent inadverte…
Browse files Browse the repository at this point in the history
…nt scroll (#11018)
  • Loading branch information
jeff-phillips-18 authored Sep 18, 2024
1 parent c10a613 commit eb245e8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/react-core/src/components/Dropdown/Dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ const DropdownBase: React.FunctionComponent<DropdownProps> = ({
'li button:not(:disabled),li input:not(:disabled),li a:not([aria-disabled="true"])'
);
firstElement && (firstElement as HTMLElement).focus();
}, 0);
}, 10);
}

// If the event is not on the toggle and onOpenChange callback is provided, close the menu
Expand Down
2 changes: 1 addition & 1 deletion packages/react-core/src/components/Select/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ const SelectBase: React.FunctionComponent<SelectProps & OUIAProps> = ({
setTimeout(() => {
const firstElement = menuRef?.current?.querySelector('li button:not(:disabled),li input:not(:disabled)');
firstElement && (firstElement as HTMLElement).focus();
}, 0);
}, 10);
}

// If the event is not on the toggle and onOpenChange callback is provided, close the menu
Expand Down

0 comments on commit eb245e8

Please sign in to comment.