Skip to content

fix(Select-next,Dropdown-next): updated logic for keyboard interaction#8496

Merged
kmcfaul merged 6 commits intopatternfly:mainfrom
thatblindgeye:iss8124_nextComponents_spaceKey
Jan 20, 2023
Merged

fix(Select-next,Dropdown-next): updated logic for keyboard interaction#8496
kmcfaul merged 6 commits intopatternfly:mainfrom
thatblindgeye:iss8124_nextComponents_spaceKey

Conversation

@thatblindgeye
Copy link
Contributor

@thatblindgeye thatblindgeye commented Jan 5, 2023

What: Closes #8124

Dropdown next preview
Select next preview

For the additional issue noted in the link above regarding adding role="option" to the underlying MenuItem, a role="listbox" and aria-multiselectable would need to be added to MenuList and aria-selected to MenuItem in order to make things more accessible.

I pushed one possible implementation where a consumer would just need to pass in selectVariant with a value of "single" or "multi" (works for either Next Select or just a plain Menu component), with that adding all the necessary attributes under the hood.

The alternative wouldn't really change anything for Next Select (consumer would still just have to pass in a prop to determine whether it's a single or multi select and everything else would be done under the hood), but when using the Menu components themselves to set something up similar to our "Option single select" and "Option multi select" examples, the role would need to be manually passed into MenuItem and MenuList.

Additional issues:

@thatblindgeye thatblindgeye marked this pull request as draft January 5, 2023 21:35
@patternfly-build
Copy link
Collaborator

patternfly-build commented Jan 5, 2023

@thatblindgeye thatblindgeye force-pushed the iss8124_nextComponents_spaceKey branch from bc3c6d8 to 66791bf Compare January 5, 2023 21:44
@thatblindgeye thatblindgeye force-pushed the iss8124_nextComponents_spaceKey branch from 66791bf to 4fd250d Compare January 13, 2023 15:39
@thatblindgeye thatblindgeye marked this pull request as ready for review January 13, 2023 15:48
/** Set the value of data-ouia-safe. Only set to true when the component is in a static state, i.e. no animations are occurring. At all other times, this value must be false. */
ouiaSafe?: boolean;
/** @beta The variant of a non-checkbox menu. Determines whether one or more items can be selected. */
selectVariant?: 'single' | 'multi';
Copy link
Contributor

Choose a reason for hiding this comment

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

Can the description mention specifically that the role and aria props are being manipulated by this prop? Maybe I'm thinking too much of the original select but currently it sounds like to me that the prop should be changing functionality / handling of selection when it doesn't.

Everything else lgtm.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes agree with Katie. The prop name is a little misleading. I am trying to think i there is a better name...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah the prop name I wasn't totally sure on. ariaSelection could maybe fit a little more, but there are non ARIA attributes being set. selectionType is another one, though may not be better than selectVariant.

I can push an update to the description and see if that would help a bit, though definitely open to updating the prop name as well if we can land on one that's more fitting.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tlabaj @kmcfaul what about, "Determines the roles and ARIA attributes for a non-checkbox menu. Only pass in if one or more menu items can be selected." as a description?

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good for the description. Name-wise I haven't been able to think of a better fitting name. roleAriaType maybe, but that's a bit unclear still. roleAndAriaType?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe using aria-multiselectable as the prop for Menu and having to pass in true or false? If the prop is undefined, the Menu isn't a non-checkbox select menu, otherwise true or false could still set the role and ARIA attributes, with the actual boolean setting the aria-multiselectable attribute itself. Or maybe ariaSelectionType to keep the "single" | "multi" typing.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe for Menu we can use aria-multiselectable and role as direct props? Then in Select/Dropdown next we can wrap them in an ariaSelectionType kind of property?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That could work... For role we could have it be to set the MenuList role, so either listbox or menu, with that determining the role of MenuItem (if role="listbox" then MenuItem would have role="option" set).;

@tlabaj wdyt?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, I think that would be much more intuitive. Good idea.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kmcfaul @tlabaj updated! Had to also add a role prop for Select Next so that a checkbox select could have role="menu" set on it (with the default being role="listbox")

@nicolethoen would you mind taking another pass in VO?

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.

VO and keyboard work as expected! LGTM

@thatblindgeye thatblindgeye force-pushed the iss8124_nextComponents_spaceKey branch from 99833a7 to 84ffa14 Compare January 20, 2023 13:56
@thatblindgeye thatblindgeye requested a review from kmcfaul January 20, 2023 13:57
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.

VO sounds good to me


return (
<Menu onSelect={onSelect} activeItemId={activeItem} selected={selectedItem}>
<Menu role="listbox" onSelect={onSelect} activeItemId={activeItem} selected={selectedItem}>
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we note the use of listbox in the text above these two updated examples? since erin has written such beautiful documentation for our Menu examples 😊

Copy link
Contributor

@tlabaj tlabaj left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@kmcfaul kmcfaul left a comment

Choose a reason for hiding this comment

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

LGTM!

@kmcfaul kmcfaul merged commit 0a343ce into patternfly:main Jan 20, 2023
@patternfly-build
Copy link
Collaborator

Your changes have been released in:

  • @patternfly/react-code-editor@4.82.109
  • @patternfly/react-core@4.276.2
  • @patternfly/react-docs@5.103.57
  • @patternfly/react-inline-edit-extension@4.86.114
  • demo-app-ts@4.210.2
  • @patternfly/react-integration@4.213.1
  • @patternfly/react-table@4.112.35
  • @patternfly/react-topology@4.91.22
  • @patternfly/react-virtualized-extension@4.88.109

Thanks for your contribution! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Select-next,Dropdown-next: Space should open menu & focus first item

6 participants