Skip to content

Studio: Solve accessibility warning on user settings - #1418

Closed
katinthehatsite wants to merge 2 commits into
trunkfrom
fix/accessibility-warning
Closed

Studio: Solve accessibility warning on user settings #1418
katinthehatsite wants to merge 2 commits into
trunkfrom
fix/accessibility-warning

Conversation

@katinthehatsite

@katinthehatsite katinthehatsite commented May 20, 2025

Copy link
Copy Markdown
Contributor

Related issues

Fixes: STU-504

Proposed Changes

When the Popover (dropdown menu) for Delete all preview sites is closed/hidden, it has aria-hidden="true" (set by WordPress components) applied to prevent screen readers from accessing its contents. However, the MenuItem still has focusable attributes (aria-disabled) even when hidden. I believe this creates a conflict because an element marked as aria-hidden="true" should not contain any focusable descendants.

Solution:
I propose to use the DropdownMenu's isOpen state to only apply focusable attributes when the menu is visible, and remove them when it's hidden. This ensures there are no focusable elements inside the Popover when it's hidden with aria-hidden="true".

This maintains proper accessibility by:

  • Allowing focus and state announcements when the menu is open
  • Properly hiding all content from screen readers when the menu is close

Sidenote: Another solution that I tried as to render the menu in the root and outside of the DOM structure by using __unstableSlotName: 'root' prop but I don't think it is a good solution to do this. Happy to discuss other alternatives as well.

Testing Instructions

  • Pull the changes from this branch
  • Start the app with npm start
  • Make sure that you have no preview sites
  • Open the developer tools
  • Navigate to User Settings in the top right corner
  • Open the Usage tab
  • Confirm click on the three dots to by Preview sites
  • Observe that when the focus goes on Delete all preview sites, there is no warning in the dev tools
  • Try switching between different tabs and site and triggering the User Settings a couple of times to confirm it works (as in the issue originally, it is not something that I could always reproduce consistently)

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?
@katinthehatsite katinthehatsite self-assigned this May 20, 2025
@katinthehatsite
katinthehatsite marked this pull request as draft May 20, 2025 13:52
@katinthehatsite
katinthehatsite requested a review from a team May 20, 2025 14:45
@katinthehatsite
katinthehatsite marked this pull request as ready for review May 20, 2025 14:45

@epeicher epeicher left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for working on this!

I have tested this and I have received the warning, I have double checked I was in this branch. Then I have moved to trunk, trying again and not getting the warning, then moved again to this branch and not getting the warning anymore 🤷 .

Sorry for not being very helpful 🙏 , but as mentioned in the issue, it seems that is not very consistent. Let me know if I can help more with this 😄

This is a screenshot of the first time I tried in this branch
CleanShot 2025-05-20 at 17 14 17@2x

@katinthehatsite

Copy link
Copy Markdown
Contributor Author

Let me take a look 🫠 Thanks for checking!

@katinthehatsite

Copy link
Copy Markdown
Contributor Author

@epeicher I discovered that the issue is a bit bigger than this so I am going to close this for now I open a different PR.

@ivan-ottinger

Copy link
Copy Markdown
Contributor

Just by coincidence, I noticed the issue while going through smoke-testing today, but similarly as Roberto pointed out, it does not get triggered consistently. 🫤

Markup on 2025-05-21 at 11:12:46

Curious to see where exactly it is coming from.

@katinthehatsite

Copy link
Copy Markdown
Contributor Author

@ivan-ottinger It comes from the wordpress/components Modal. I explained a bit more in #1423 and proposed a different fix. It also affects multiple places not just User settings

@wojtekn
wojtekn deleted the fix/accessibility-warning branch July 11, 2025 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants