Skip to content

[Tooltip] Stays visible when scrolling away #44548

Done

Description

@BTish

Steps to reproduce

Steps:

  1. Open this link to live example
  2. Hover over one of the tooltips in the Last Name column
  3. Scroll away (without moving the mouse)
  4. You'll notice the tooltip stays open

Current behavior

The tooltip stays open on scroll .

Expected behavior

The tooltip should close when scrolled away from.

Context

We are using a tooltip inside of a data grid. When a user hovers the tooltip, we have an api call that happens to populate the it's contents. This call takes milliseconds to complete. When a user hovers the tooltip, and scrolls in the Datagrid, the tool tip stays open even though the user's cursor is no longer hovering the tooltip.

Order ID: 80452

Your environment

npx @mui/envinfo
  Don't forget to mention which browser you used.
  Output from `npx @mui/envinfo` goes here.

Search keywords: Tooltip, stays open, tooltip hover

Activity

  1. added
    status: waiting for maintainer
    on Nov 25, 2024
  2. added
    scope: tooltip
    on Nov 26, 2024
  3. aarongarciah commented on Nov 26, 2024

    @aarongarciah
    Member

    I'm able to reproduce the behavior you describe. Not sure if it can be considered a bug or not.

    React Aria and Radix close the tooltip as soon as the cursor leaves the trigger, no matter if a scroll event or the user moving te cursor caused it. Ariakit has the same behavior as the one in Material UI: the tooltip is not closed when the cursor leaves the trigger because of the user scrolling; it's only closed after the user moves the cursor.

  4. BTish commented on Nov 26, 2024

    @BTish
    Author

    @aarongarciah - Thanks for the quick reply.

    I've updated the stackblitz code to have a timeout to simulate an api call to set the text and opening the tool tip (This is what we're doing in our application). If you hover over one, and quickly move to a different one or scroll, you'll be able to tell when you even move the mouse, that the tooltip stays open.

  5. mj12albert commented on Nov 27, 2024

    @mj12albert
    Member

    Closing when the cursor leaves the trigger no matter the reason (scroll, actual cursor move) feels more correct to me. It would also be closer to how the behavior is described in:

    The ARIA pattern (though a WIP):

    (the tooltip) remains open as long as the cursor is over the trigger or the tooltip.

    Material Design 2:

    Tooltip disappears when cursor moves out of the touch target

  6. aarongarciah commented on Nov 27, 2024

    @aarongarciah
    Member

    @BTish I agree with @mj12albert. What you're trying to achieve is outside of a tooltip pattern.

    Maybe a Popover is better suited for your use case. We had a recent issue where this was discussed, see #44554 (comment). Tooltips are meant to display secondary info (e.g. provide more context on a button that performs an action) while popovers are meant to display primary info and the sole purpose of the popover trigger is to open the trigger. Let me know if this helps.

    In a future major version, once we adopt Base UI in Material UI's Popover, we'll have first-class support to open Popovers via hover.

  7. mj12albert commented on Nov 27, 2024

    @mj12albert
    Member

    What you're trying to achieve is outside of a tooltip pattern.

    Wait, regardless of the use-case, we are all agreeing with OP's reported current and expected behavior right? (the Datagrid part isn't relevant)

    Current behavior
    The tool tip stays open on scroll inside a Datagrid.

    Expected behavior
    The tool tip should close when scrolled away from.

    I think this could be considered a bug 🤔

  8. aarongarciah commented on Nov 27, 2024

    @aarongarciah
    Member

    @mj12albert I mixed a couple of issues in my previous response, sorry about that. I redacted my comment. I agree, closing the Tooltip when scrolling away seems a better default. Do you know how this will be handled in the Base UI rewrite? AFAIK the tooltip is closed when scrolling away but only after the user has stopped scrolling.

    @BTish if the content you're displaying in the Tooltip is something that's vital for the UX and not something secondary, maybe Popover is a better fit for your use case.

  9. BTish commented on Nov 27, 2024

    @BTish
    Author

    @BTish if the content you're displaying in the Tooltip is something that's vital for the UX and not something secondary, maybe Popover is a better fit for your use case.

    Sounds great. Thanks @aarongarciah. I've talked with our UI/UX and we're going to go with the Popover route.

  10. changed the title [-][Tooltip] Tooltip stays on when scrolling in a DataGrid[/-] [+][Tooltip] Tooltip stays visible when scrolling away[/+] on Nov 27, 2024
  11. changed the title [-][Tooltip] Tooltip stays visible when scrolling away[/-] [+][Tooltip] Stays visible when scrolling away[/+] on Nov 27, 2024
  12. removed
    status: waiting for maintainer
    on Nov 27, 2024
  13. aarongarciah commented on Nov 27, 2024

    @aarongarciah
    Member

    Nice @BTish. I'll keep this issue open so we tackle this in the future although this issue will probably be solved once we adopt Base UI.

  14. removed their assignment
    on Dec 3, 2024
  15. added
    type: bug
    on Dec 5, 2024
  16. ZeeshanTamboli commented on Nov 27, 2026

    @ZeeshanTamboli
    Member

    Closing this. See #49815 (comment)

  17. github-actions commented on Nov 27, 2026

    @github-actions
    Contributor

    This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue.
    Now, if you have additional information related to this issue or things that could help future readers, feel free to leave a comment.


    @BTish Thanks again for creating this issue! If you have a moment, we would love to hear your thoughts on how we handled it with this short feedback form.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    scope: tooltiptype: bug

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions