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

Conversation

jeff-phillips-18
Copy link
Member

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.

@patternfly-build
Copy link
Contributor

patternfly-build commented Sep 18, 2024

Copy link
Contributor

@thatblindgeye thatblindgeye left a 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);
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.

@thatblindgeye thatblindgeye merged commit eb245e8 into patternfly:v5 Sep 18, 2024
13 checks passed
@patternfly-build
Copy link
Contributor

Your changes have been released in:

  • @patternfly/react-code-editor@5.4.2
  • @patternfly/react-core@5.4.1
  • @patternfly/react-docs@6.4.2
  • @patternfly/react-drag-drop@5.4.1
  • demo-app-ts@5.4.2
  • @patternfly/react-table@5.4.1
  • @patternfly/react-templates@1.1.1

Thanks for your contribution! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants