Skip to content

chore(dropdown): add split button action example #11753

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

@Mash707
Copy link
Contributor Author

Mash707 commented Apr 10, 2025

@kmcfaul @thatblindgeye I have created a draft for the example. Let me know of the changes required.
Also could you guys also suggest the description and sub heading for the example, I am not sure of it. Thank You

@patternfly-build
Copy link
Contributor

patternfly-build commented Apr 10, 2025

@Mash707
Copy link
Contributor Author

Mash707 commented Apr 10, 2025

There were some a11y issues regarding MenuToggle and MenuToggleCheckbox since I didn't add aria-label to them.
@thatblindgeye do check the aria-labels once, I have added them for now so that the tests don't fail.

Copy link
Contributor

@nicolethoen nicolethoen left a comment

Choose a reason for hiding this comment

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

Event handling is not quite ideal in this example.

In other dropdown examples, if I open the menu using the keyboard, i can hit tab and it will close the menu and put focus on the next focusable element on the page (in the docs, that's usually the button)

In the other dropdown examples, I can also click outside the menu and it will close the menu.

I think it's because this new example might be missing the 'onOpenChange' prop.

@Mash707 Mash707 force-pushed the dropdown-add-split-action-example branch from 6073673 to 6adca58 Compare April 23, 2025 19:57
@Mash707
Copy link
Contributor Author

Mash707 commented Apr 23, 2025

Yes, it was happening due to the missing onOpenChange prop. I have added it and now the menu is closing when clicking outside.

@Mash707 Mash707 requested a review from nicolethoen April 23, 2025 19:59
Copy link
Contributor

@nicolethoen nicolethoen left a comment

Choose a reason for hiding this comment

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

I'm noticing that if I select an option from the menu (with they keyboard or my mouse) browser focus is not returned to the MenuToggle as it does in other examples.

I think you're also missing the shouldFocusToggleOnSelect prop

@Mash707
Copy link
Contributor Author

Mash707 commented Apr 28, 2025

When adding the shouldFocusToggleOnSelect , it does not seem to work with splitButtonItems prop of the menu toggle. If I remove the splitButtonItems prop then it is working fine.
I also added splitButtonItems to others examples to test things out and it breaks them too.

@thatblindgeye
Copy link
Contributor

thatblindgeye commented Apr 28, 2025

Looks like it's because we're applying the innerref inside MenuToggle to that wrapper div instead of the toggle button:

if (splitButtonItems) {
return (
<div ref={innerRef as React.Ref<HTMLDivElement>} className={css(commonStyles, styles.modifiers.splitButton)}>

Since it's a plain div without any tabindex focus gets lost when trying to focus it, and we end up back at the top of the page when you Tab again. This PR is what added the ref to that div #8024 . @kmcfaul do you recall if we need to have the ref on this wrapper div? Moving it to the button toggle for the splitButtonItems return seems more accurate in this case, but can't remember if there was a specific reason.

An alternative would be possibly having to supply some custom focus logic in the example code, which consumers would then have to also implement.

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.

Dropdown - split button action example
4 participants