Skip to content

[web] Ensure Sidebar siblings do not remain inert forever #572

Merged
dgdavid merged 4 commits intomasterfrom
improve-sidebar-siblings-manipulation
May 11, 2023
Merged

[web] Ensure Sidebar siblings do not remain inert forever #572
dgdavid merged 4 commits intomasterfrom
improve-sidebar-siblings-manipulation

Conversation

@dgdavid
Copy link
Contributor

@dgdavid dgdavid commented May 10, 2023

Problem

As mentioned in patternfly/patternfly-react#9096, #564 revealed that unmounting a PF4/Modal component results in its siblings remaining hidden from the accessibility API.

Since #563 followed the same pattern of hiding the Sidebar siblings, it may suffer the same problem if it is unmounted (although it is not supposed to happen). Therefore, it would be better to minimize the risk of keeping siblings inert if the Sidebar is unmounted in the future.

Solution

To remove the inert and aria-hidden attributes from its siblings BEFORE the Sidebar is unmounted. Note the use of useLayoutEffect for doing so while the component still having access to the parent and its children.

Testing

  • Added another unit test

  • Tested manually

Notes

Screenshots

N/A

dgdavid added 2 commits May 10, 2023 22:40
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.
@coveralls
Copy link

coveralls commented May 10, 2023

Pull Request Test Coverage Report for Build 4945512932

  • 12 of 12 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.02%) to 74.755%

Totals Coverage Status
Change from base Build 4935953185: 0.02%
Covered Lines: 5039
Relevant Lines: 6502

💛 - Coveralls

@dgdavid dgdavid marked this pull request as ready for review May 11, 2023 07:51
@dgdavid dgdavid requested a review from imobachgs May 11, 2023 07:54
Copy link
Contributor

@joseivanlopez joseivanlopez left a comment

Choose a reason for hiding this comment

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

LGTM

@dgdavid dgdavid merged commit b2ab3f8 into master May 11, 2023
@dgdavid dgdavid deleted the improve-sidebar-siblings-manipulation branch May 11, 2023 08:20
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.

4 participants