Skip to content

[TrapFocus] Entangle effects#22155

Merged
eps1lon merged 6 commits intomui:nextfrom
eps1lon:feat/TrapFocus/entangle
Aug 14, 2020
Merged

[TrapFocus] Entangle effects#22155
eps1lon merged 6 commits intomui:nextfrom
eps1lon:feat/TrapFocus/entangle

Conversation

@eps1lon
Copy link
Member

@eps1lon eps1lon commented Aug 11, 2020

breaking change
re-enabling the restore focus logic while open by flipping disableRestoreFocus from true to false no longer has an effect. It only worked if disableRestoreFocus was flipped in a separate commit but not if disableRestoreFocus and open where flipped.

The current usage started with the old lifecycle model but started to add dependencies that weren't used by some effects. Effects should each live in their own useEffect not one single componentDidMount.

The tests introduced in this PR fail on next. Only undesired: setting disableRestoreFocus to false before closing has no effect had the desired behavior on next. I think I can make this use case work though.

This PR is part of the changes required to make this component work with React 17. Entangling the effects makes it easier to reason about the behavior. In the end I don't think it's viable to run the restore focus logic in the cleanup. I need a codesandbox to experiment with it though.

@eps1lon eps1lon added type: bug It doesn't behave as expected. breaking change Introduces changes that are not backward compatible. scope: focus trap Changes related to the focus trap. labels Aug 11, 2020
@mui-pr-bot
Copy link

mui-pr-bot commented Aug 11, 2020

Details of bundle changes

Generated by 🚫 dangerJS against 9655dc5

@eps1lon eps1lon merged commit 862fade into mui:next Aug 14, 2020
@eps1lon eps1lon deleted the feat/TrapFocus/entangle branch August 14, 2020 07:09
@eps1lon eps1lon added this to the v5 milestone Sep 15, 2020
@oliviertassinari oliviertassinari mentioned this pull request Sep 15, 2020
42 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking change Introduces changes that are not backward compatible. scope: focus trap Changes related to the focus trap. type: bug It doesn't behave as expected.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants