returnFocusOnDeactivate does not work when using active prop
See original GitHub issueIve noticed that when you are using the active
prop, there is code which ignores the returnFocusOnDeactivate
option. Is this intentional?
I would of thought that the componentDidUpdate
function should be this:
componentDidUpdate(prevProps) {
if (prevProps.active && !this.props.active) {
const { focusTrapOptions } = this.props;
const returnFocus = focusTrapOptions.returnFocusOnDeactivate || false;
this.focusTrap.deactivate({ returnFocus });
} else if (!prevProps.active && this.props.active) {
this.focusTrap.activate();
}
if (prevProps.paused && !this.props.paused) {
this.focusTrap.unpause();
} else if (!prevProps.paused && this.props.paused) {
this.focusTrap.pause();
}
}
that way - when the focus trap is made inactive, then we still get the returnFocus
behaviour.
Im happy to P.R this if I am correct in understanding the intended behaviour.
Cheers.
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
returnFocusOnDeactivate does not work when using active prop
Ive noticed that when you are using the active prop, there is code which ignores the returnFocusOnDeactivate option. Is this intentional?
Read more >focus-trap-react - UNPKG
105, - Fix: `specifiedFocusTrapOptions.includes(optionName)` statement in `componentDidMount()` was causing an exception because `includes()` is not a function ...
Read more >How to use the focus-trap function in focus-trap - Snyk
Use Snyk Code to scan source code in minutes - no build needed - and fix issues ... console.log('Focus trap not activated -...
Read more >Unknown prop "active" using LinkContainer with MenuItem ...
The active prop can be applied only for Link component. But your problem can be fixed within MenuItem component. Intead of passing all...
Read more >Vue component to trap the focus within a DOM element
FocusTrap can be controlled in three different ways: by using the active Boolean prop; by using v-model (uses the active prop) ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Published as 4.0.1.
I’m still seeing an issue on 6.0.0 where
returnFocusOnDeactivate
doesn’t seem to be respected. I’m also using theactive
prop. I can’t tell where the failure is, though.