Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(dropdown): Delay setting focus on first item to prevent inadvertent scroll #11018

Merged
merged 1 commit into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
Copy link
Contributor

@thatblindgeye thatblindgeye Sep 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tlabaj wdyt about using a (beta) prop for this timeout amount? Wondering just based on how this issue has come up several times if we can rely on a static timeout without the potential to have to slowly increase it if the issue comes up again.

It'd also be a very specific prop, though, and possibly one we wouldn't need if we refactor things and move to Floating UI/another popper alternative.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. we can do that as follow up.

}

// 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
Loading