Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Tooltip] [Dialog] [Menu-Button] Tooltips get disabled forever if component is rendered conditionally #714

Open
nulladdict opened this issue Dec 21, 2020 · 3 comments
Labels
Status: Investigation Type: Bug Something isn't working

Comments

@nulladdict
Copy link

🐛 Bug report

Current Behavior

Tooltips get disabled when isOpen prop changes (or when the dialog is mounted), and get re enabled in raf.
However, if the dialog gets unmounted tooltips do not get re enabled.

Expected behavior

Tooltips get re enabled when dialog is unmounted

Reproducible example

Codesandbox link

Suggested solution(s)

I think we should enable tooltips in raf when dialog gets unmounted

Your environment

Software Name(s) Version
Reach Package dialog, tooltip 0.12.1
React latest
Browser any any
Assistive tech any
Node stable
npm/yarn stable
Operating System any any
@nulladdict
Copy link
Author

nulladdict commented Dec 21, 2020

I think this lines are responsible for the behaviour, and it looks like it should be something like this instead: (upd: ignore this, this breaks tooltips inside Dialog)

React.useEffect(() => {
  if (isOpen) {
    // @ts-ignore
    window.__REACH_DISABLE_TOOLTIPS = true;
    return () => {
      window.requestAnimationFrame(() => {
        // Wait a frame so that this doesn't fire before tooltip does
        // @ts-ignore
        window.__REACH_DISABLE_TOOLTIPS = false;
      });
    };
  }
}, [isOpen]);

@nulladdict
Copy link
Author

I've noticed there is also a problem if <Menu /> is rendered conditionally.
If menu is unmounted while being in the open state (for example MenuItem might delete the object that had the open menu) tooltips no longer work from focus.
The cause (no cleanup in the effect) and solution (adding it) are similar.

@nulladdict nulladdict changed the title [Tooltip] [Dialog] Tooltips get disabled forever if dialog is rendered conditionally [Tooltip] [Dialog] [Menu-Button] Tooltips get disabled forever if dialog is rendered conditionally Dec 22, 2020
@nulladdict nulladdict changed the title [Tooltip] [Dialog] [Menu-Button] Tooltips get disabled forever if dialog is rendered conditionally [Tooltip] [Dialog] [Menu-Button] Tooltips get disabled forever if cimponent is rendered conditionally Dec 22, 2020
@nulladdict
Copy link
Author

I've also noticed that tooltips nested in the Dialog no longer show up after #521, even though #390 states it shouldn’t be the case

@nulladdict nulladdict changed the title [Tooltip] [Dialog] [Menu-Button] Tooltips get disabled forever if cimponent is rendered conditionally [Tooltip] [Dialog] [Menu-Button] Tooltips get disabled forever if component is rendered conditionally Dec 22, 2020
@chaance chaance added Status: Investigation Type: Bug Something isn't working labels Dec 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Investigation Type: Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants