question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

returnFocusOnDeactivate does not work when using active prop

See original GitHub issue

Ive 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:closed
  • Created 5 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
davidtheclarkcommented, Sep 23, 2018

Published as 4.0.1.

0reactions
walt-ercommented, Jun 3, 2019

I’m still seeing an issue on 6.0.0 where returnFocusOnDeactivate doesn’t seem to be respected. I’m also using the active prop. I can’t tell where the failure is, though.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found