-
Notifications
You must be signed in to change notification settings - Fork 353
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
fix(dropdown): Delay setting focus on first item to prevent inadvertent scroll #11018
Conversation
Preview: https://patternfly-react-pr-11018.surge.sh A11y report: https://patternfly-react-pr-11018-a11y.surge.sh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does look to work when testing the Table with actions example. In v5 org i can replicate the scroll jump bug in that example, but in this PR I haven't been able to (trying to open the kebab menu with the page scrolled to various points).
@@ -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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Your changes have been released in:
Thanks for your contribution! 🎉 |
What:
Closes #10896
Description:
Add a slight delay before setting focus on the first dropdown item when
shouldFocusFirstItemOnOpen
is set. This gives enough time for the popover to be shown in the correct location so the scrollable doesn't scroll to the invalid location.