eui icon indicating copy to clipboard operation
eui copied to clipboard

[EuiTooltip] Scrolls off the anchor upon page or parent scroll

Open awahab07 opened this issue 3 years ago • 4 comments

Summary

EuiTooltip attached to a button scrolls off the button when parent is scrolled. This might be only happening when the anchor element is itself on a popover. As is the below snapshot, the tooltip is attached to a button where the button is inside an overlay container (bottom sheet).

Screenshot 2022-02-04 at 15 39 56

Video for reference:

https://user-images.githubusercontent.com/2748376/152554849-aeff9fd8-8b16-48be-baba-cb047856b747.mov

Consumer code for reference:

<EuiFlexItem grow={false} style={{ marginRight: 20 }}>
  <EuiToolTip content={TEST_NOW_DESCRIPTION}>
    <EuiButton
      fill
      size="s"
      color="success"
      iconType="play"
      onClick={() => onTestNow()}
      disabled={!isValid}
      data-test-subj={'monitorTestNowRunBtn'}
    >
      {testRun ? RE_RUN_TEST_LABEL : RUN_TEST_LABEL}
    </EuiButton>
  </EuiToolTip>
</EuiFlexItem>

Proposals 1:

Implement a prop repositionOnScroll on EuiTooltip which should reposition the tooltip when scrolled. EuiPopover already implements it, see. Also see RepositionScrollStrategy in Angular CDK Overlay.

Proposal 2:

Implement a prop hideOnScroll on EuiTooltip (and maybe also on EuiPopover) that when set to true, hides the tooltip when any scroll event happens in the scope of window. See CloseScrollStrategy in Angular CDK Overlay.

Proposal 3:

Implement both 1 and 2 above.

awahab07 avatar Feb 04 '22 15:02 awahab07

Just noting (after a refresher in the code) that EuiToolTip does not use EuiPopover, but instead uses one of its utils and mimics the behavior with EuiPortal + EuiToolTipPopover. Unless someone already has context on why this was done and whether it's still necessary/desired, it's probably worth exploring whether using EuiPopover is possible. In that case, we could just pass through the repositionOnScroll prop. Another option is to extract the positionPopover method from EuiPopover and make it available elsewhere as a util.

thompsongl avatar Feb 04 '22 16:02 thompsongl

The tooltip & popover components existed before popover's positioning logic came to be; that change never made its way into tooltips.

TBH the reposition logic should probably be on by default, it creates a small overhead during scroll (and browsers try to limit potential blocking of the UI) but it'd be better to not have the popover/tooltip fly away from its anchor.

chandlerprall avatar Feb 08 '22 19:02 chandlerprall

👋 Hey there. This issue hasn't had any activity for 180 days. We'll automatically close it if that trend continues for another week. If you feel this issue is still valid and needs attention please let us know with a comment.

github-actions[bot] avatar Aug 08 '22 00:08 github-actions[bot]

Had another report of this behavior today. Remains not high priority at the moment, but adding a label to ensure it doesn't get lost.

thompsongl avatar Aug 18 '22 20:08 thompsongl

Team, can we please priorities fix for this? it's annoying when this happens.

shahzad31 avatar Dec 28 '22 09:12 shahzad31

There is a simple workaround though. If you change tooltip key, when it's disabled etc it will force re-render. that seems to resolve the issue.

shahzad31 avatar Dec 28 '22 13:12 shahzad31

We've prioritized this issue and labeled it as a bug.

daveyholler avatar Jan 09 '23 19:01 daveyholler

This has been resolved in https://github.com/elastic/eui/pull/6515 - as of the next release/Kibana upgrade, you'll be able to add <EuiToolTip repositionOnScroll> to get this working!

cee-chen avatar Jan 10 '23 20:01 cee-chen

I added repositionOnScroll on my EuiPopover but it repositions after a delay which does not look very nice

lizaemran avatar Feb 23 '24 05:02 lizaemran