Skip to content

Conversation

rebeccaalpert
Copy link
Member

@rebeccaalpert rebeccaalpert commented Oct 14, 2025

Example was using out-of-date PatternFly syntax from a prior version. It should now show how to properly add a dropdown to a modal that allows for keyboard accessibility.

What: Closes #11847

Additional issues:

@rebeccaalpert rebeccaalpert marked this pull request as ready for review October 14, 2025 17:43
@patternfly-build
Copy link
Contributor

patternfly-build commented Oct 14, 2025

@rebeccaalpert rebeccaalpert requested review from a team, dlabaj and nicolethoen and removed request for a team October 14, 2025 17:44
Example was using out-of-date PatternFly syntax from a prior version. It should now show how to properly add a dropdown to a modal that allows for keyboard accessibility.
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 looks good to me, some comments below that would probably be worth discussing/implementing, just because I believe consumers have raised issue with menus inside Modal's causing a scrollbar so it'd be good for us to convey how to avoid that with this example update.

To present a menu of actions or links to a user, you can add a [dropdown](/components/menus/dropdown) to a modal.

To allow the dropdown to visually break out of the modal container, set the `menuAppendTo` property to parent. Handle the modal’s closing behavior by listening to the `onEscapePress` callback on the `<Modal>` component. This allows the "escape" key to collapse the dropdown without closing the entire modal.
To allow the dropdown to visually break out of the modal container, set the `popperProps appendTo` property to one of the parent content items in the modal. Otherwise you can use `inline` to allow it to scroll within the modal itself. Using the Dropdown's default append location will interfere with keyboard accessibility due to the modal's built-in focus trap. Handle the modal’s closing behavior by listening to the `onEscapePress` callback on the `<Modal>` component. This allows the "escape" key to collapse the dropdown without closing the entire modal.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the updates here look good for how we have the example currently setup, but it'd be worth mentioning that appending to the .pf-v6-l-bullseye element could be used for dropdowns/selects that have a lot of items that would cause that Modal scrollbar, if that isn't the desired result. Appending to the bullseye should allow the menu to expand visually outside the Modal (no scrollbar created in the Modal itself), and still allow focusing the content within that menu via keyboard.

Comment on lines 53 to 54
if (typeof document !== 'undefined' && document.getElementById) {
return document.getElementById('modal-box-body-with-dropdown');
Copy link
Contributor

Choose a reason for hiding this comment

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

Just as a relation to my above comment, updating these lines to:

Suggested change
if (typeof document !== 'undefined' && document.getElementById) {
return document.getElementById('modal-box-body-with-dropdown');
if (typeof document !== 'undefined' && document.querySelector) {
return document.querySelector('.pf-v6-l-bullseye');

Should result in behavior consumers might expect/want (the menu not creating a Modal scrollbar).

Going this far, though, maybe it'd be useful to add props within the ModalContent component to allow adding a unique ID to the FocusTrap wrapper that gets the bullseye class applied.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't mind - pushing this since it's more specific.

/**
* This test was not generated
*/
test('Focus trap can have an id added', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

One last thing, if we can let's move this to a separate test file outside the Generated directory.

If you'd want to also add a snapshot test to that new file, we could probably delete the Generated test directory altogether

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.

Bug - Dropdown - aria-hidden still set on dropdowns after click

3 participants