reach/reach-ui

Tooltip bonanza bug

Closed this issue ยท 18 comments

Noticed this issue testing the React profiler:
@reach-tooltip-bug-Kapture 2019-05-07 at 14 52 16

Can be reproduced by going here and importing this profiling.json export.

I am working on a smaller repro but haven't yet figured it out. ๐Ÿ˜…

Note that this bug occurs in tooltip versions 0.1 and 0.2.

Here's a smaller repro:
https://qkyvl35j09.codesandbox.io/

bug-Kapture 2019-05-07 at 15 20 32

I've seen this issue a few times in my project as well, though I can't figure out the steps to reproduce it as consistently as your example ^

@bvaughn I noticed that the tooltip bug doesn't happen if you remove the Tooltip from the initial repro button. Possibly a timing/subscriptions issue?

https://codesandbox.io/s/reachtooltip-bonanza-bug-repro-k8fwg

Fair enough, although that's not really an option in my project (DevTools) since that button needs a tooltip as well :)

Totally understand. I was just hinting towards a possible cause for the issue, our team is in the same boat!

I found a possible solution. Though, I want to make sure that it does not have an unintended side effects before I post a PR.

@bvaughn, I was able to correct all the tooltips showing upon transition with my WIP solution. However, your demo does shift focus away from and back to the button that was originally clicked (default browser behavior, AFAIK). I added a red outline to the focused element in the GIF below demoing my solution. Is this your desired behavior?

2019-06-11 16 08 50

I'm not really sure what you're asking. I don't explicitly set focus, so... it seems like if the browser's default behavior causes tooltips to break, that's not good. (There are a few cases where this happens in DevTools. This was just one repro I was able to isolate.)

I'm asking what you're expected behavior is. I can see that there is something off, but I'm not sure what you're expected behavior is. Given the patch I've written I would say that it is almost there. As only the focused element is given a tooltip. However, I do think that the element ID assignment could be better as previously used IDs are automatically used again upon the removal of a node with a reserved ID.

So, as it stands right now. I'm not sure what should be done, @ryanflorence.

Gotcha.

I'm asking what you're expected behavior is.

My expectation is just that every tooltip won't show at once. I don't actually have much of an expectation about whether the single tooltip would show (or not) on return focus. Slight preference for "not" but I can understand if this would be difficult to achieve.

My expectation is just that every tooltip won't show at once.

If that is the case, then I believe my patch will address that. I suppose I'll just post a PR and we can continue from there.

Thanks for digging in @SavePointSam! This is a bug that would prevent us from using it in production, but we love it otherwise. Hopefully we can hear back soon from Ryan if he's ok with your solution.

I'll take a look at this today, thanks everybody :)

Also, just noticed the name of this issue, @bvaughn you crack me up ๐Ÿ˜‚

@ryanflorence any plans to merge my fix soon?

Looks like the fix is in 0.2.2! Thanks so much @ryanflorence and @SavePointSam , this will be going out to some very happy users (and devs) in the next month. Our previous tooltip implementation was a mess.

Thanks Ryan and Sam!

I believe this can be closed now. ๐Ÿ˜„๐Ÿš€