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

ui,ui-components: Tooltip is mis-centered for inline targets #72003

Closed
jocrl opened this issue Oct 26, 2021 · 2 comments
Closed

ui,ui-components: Tooltip is mis-centered for inline targets #72003

jocrl opened this issue Oct 26, 2021 · 2 comments
Labels
A-webui Triage label for DB Console (fka admin UI) issues. Add this if nothing else is clear. C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. no-issue-activity X-stale

Comments

@jocrl
Copy link
Contributor

jocrl commented Oct 26, 2021

Problem:
cockroachdb/ui#290 introduced a wrapping div around the target children for the ui-components Tooltip component. This causes inline target elements (e.g. buttons) wrapped by Tooltip to behave like block elements within their parent component, including mis-centering the tooltip at the center of the block instead of the at the center of the inline element.

cockroachdb/ui#396 adds a story that demonstrates this:

image

The goal of cockroachdb/ui#290 was to make it so that if your mouse continued to stay over the tooltip it would not leave, allowing users to click on links in the tooltip. A naive attempt of moving these props (https://github.com/cockroachdb/ui/pull/290/files#diff-f78af0a31de2edadb9ecd5ac3f5ed5999c1f9a66965d75b74da494b7d3c8ea49R79) with the introduced timeout directly to the child component (where they used to be, https://github.com/cockroachdb/ui/pull/290/files#diff-f78af0a31de2edadb9ecd5ac3f5ed5999c1f9a66965d75b74da494b7d3c8ea49L72) broke the ability to keep the tooltip open by hovering open the tooltip. It looks like the code works precisely because the enclosing div encompasses the tooltip body in addition to the target.

Solution:
Keeping the tooltip open while hovering the tooltip (not just the target) should be modified/reimplemented in a way that does not introduce an enclosing div.

Implementation suggestion:
The "react tooltip" library has an implementation of keeping the tooltip open when the tooltip body is hovered https://github.com/wwayne/react-tooltip/blob/master/src/index.js#L222. The react-bootstrap and chakra libraries' tooltips do not have this feature.

Additional suggestion that would go well with this:
When the enclosing div is removed, the code would likely go back to assuming that there is only one child (passing the one target ref to multiple children would be weird). Calling React.Children.only(children) or verifying the children count would be helpful to enforce this.

Jira issue: CRDB-10894

@jocrl jocrl changed the title Tooltip [ui-components] Tooltip mis-centered with inline targets Oct 26, 2021
@jocrl jocrl changed the title [ui-components] Tooltip mis-centered with inline targets [ui-components] Tooltip is mis-centered for inline targets Oct 26, 2021
@jocrl jocrl transferred this issue from cockroachdb/ui Oct 26, 2021
@blathers-crl
Copy link

blathers-crl bot commented Oct 26, 2021

Hi @jocrl, I've guessed the C-ategory of your issue and suitably labeled it. Please re-label if inaccurate.

While you're here, please consider adding an A- label to help keep our repository tidy.

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is otan.

@blathers-crl blathers-crl bot added the C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) label Oct 26, 2021
@jocrl jocrl added C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. and removed C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) labels Oct 26, 2021
@jocrl jocrl added the A-webui Triage label for DB Console (fka admin UI) issues. Add this if nothing else is clear. label Oct 26, 2021
@jocrl jocrl changed the title [ui-components] Tooltip is mis-centered for inline targets ui,ui-components: Tooltip is mis-centered for inline targets Oct 26, 2021
@github-actions
Copy link

We have marked this issue as stale because it has been inactive for
18 months. If this issue is still relevant, removing the stale label
or adding a comment will keep it active. Otherwise, we'll close it in
10 days to keep the issue queue tidy. Thank you for your contribution
to CockroachDB!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-webui Triage label for DB Console (fka admin UI) issues. Add this if nothing else is clear. C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. no-issue-activity X-stale
Projects
None yet
Development

No branches or pull requests

1 participant