Skip to content

Conversation

@dgdavid
Copy link
Contributor

@dgdavid dgdavid commented May 9, 2023

What

At Agama project, we've found an issue with the aria-hidden attributes added by the PatternFly Modal component: some dialogs do not remove them.

As far as I can see, this happens to us with open dialogs that are included dynamically. I.e., dialogs that are mounted as open and then simply unmounted instead of closed.

Of course, we should re-evaluate such a use case and stop doing so if we do not have strong reasons for it. However, it looks straight forward and safe to trigger the logic for removing these attributes when the component is unmounted too. I cannot envision a scenario where this would not be convenient

Additional issues

Prior to digging into the problem, I quickly searched the issue list and found #8925. Based on a quick glance at the linked source code, the problem appears to be the same: the MemberModal is unmounted, not closed, so the aria-hidden attributes remain.

Other notes

Just in case it can be useful for someone else doing a first contribution to patternfly/patternfly-react:

Getting the project working locally was a bit challenging to me because neither GETTING-STARTED.md nor the CONTRIBUTING.md helped me to understand the errors related to missing modules/dependencies I got at the beginning when trying either, to build the project and to run the test suite. The Getting Started as a Contributor guide looks outdated too.

Fortunately, I could get some hints about how to move forward from the Maintainer's Guide and the dist CI partial. Summarizing:

  • DO NOT use npm install
  • Use yarn install instead (you might need to install yarn first)
  • Run yarn build && yarn build:umd
  • Run yarn test

Furthermore, I learned how to run a single test in a project using yarn workspaces. In my case, I have used below command from the root of the project

yarn jest packages/react-core/src/components/Modal/__tests__/Modal.test.tsx -c jest.config.js 

and also I run the linter with

yarn eslint --no-ignore packages/react-core/src/components/Modal/__tests__/Modal.test.tsx

The component adds the aria-hidden attribute to its siblings when open
and removes it when closed. However, if the component is mounted as open
but then directly unmounted, its siblings will remain hidden from the
accessibility API forever.

Thus, the logic for removing these attributes is now also triggered when
the component is unmounted.
@dgdavid dgdavid force-pushed the modal-aria-hidden-improvements branch from 012dfef to cc08a57 Compare May 9, 2023 21:36
@patternfly-build
Copy link
Contributor

patternfly-build commented May 9, 2023

@dgdavid dgdavid force-pushed the modal-aria-hidden-improvements branch from daf880f to 4a86c93 Compare May 9, 2023 21:48
dgdavid added a commit to agama-project/agama that referenced this pull request May 10, 2023
While unmounting the Sidebar is unlikely to happen, it's better to make
the component a good citizen by "restoring" its siblings by removing the
`inert` and `aria-hidden` attributes. That way, we're minimizing the
risk of users being trapped in an issue similar to the one described at
patternfly/patternfly-react#9096

Please note that at the time of writing it's not a real restore because
the component isn't tracking the status of these attributes BEFORE
adding them. However, removing the supposedly added attributes seems
enough for now.
@tlabaj
Copy link
Contributor

tlabaj commented May 16, 2023

Hi @dgdavid. Thank you for the contribution. Our repo is code frozen right now and we are working towards a major release of PF. We can take a look at this issue and work on getting your PR in once we open repos again. Q3 is the earliest this would get released.

dgdavid added a commit to agama-project/agama that referenced this pull request May 17, 2023
When a PF4/Modal is unmounted instead of set as `isOpen={false}`, its
siblings remain as `aria-hidden`. To know more read
patternfly/patternfly-react#9096
dgdavid added a commit to agama-project/agama that referenced this pull request May 17, 2023
When a PF4/Modal is unmounted instead of set as `isOpen={false}`, its
siblings remain as `aria-hidden`. To know more read
patternfly/patternfly-react#9096
dgdavid added a commit to agama-project/agama that referenced this pull request May 17, 2023
When a PF4/Modal is unmounted instead of set as `isOpen={false}`, its
siblings remain as `aria-hidden`. To know more read
patternfly/patternfly-react#9096
@stale
Copy link

stale bot commented Aug 5, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the wontfix label Aug 5, 2023
@stale stale bot closed this Aug 21, 2023
@dgdavid
Copy link
Contributor Author

dgdavid commented Sep 26, 2023

Just for the record, this change was already merged in v5 (current main branch) but automatically closed by the stale bot for v4.

dgdavid added a commit to agama-project/agama that referenced this pull request Oct 19, 2023
dgdavid added a commit to agama-project/agama that referenced this pull request Oct 19, 2023
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.

3 participants