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 |
thatblindgeye
left a comment
There was a problem hiding this comment.
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).
| ); | ||
| firstElement && (firstElement as HTMLElement).focus(); | ||
| }, 0); | ||
| }, 10); |
There was a problem hiding this comment.
@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.
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
shouldFocusFirstItemOnOpenis 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.