palantir / blueprint

A React-based UI toolkit for the web
https://blueprintjs.com/
Apache License 2.0
20.64k stars 2.17k forks source link

FR: MenuItems should allow tooltips #926

Open kmwhelan93 opened 7 years ago

kmwhelan93 commented 7 years ago

Especially if a menu item is disabled, a tooltip explanation would be very helpful for users.

Note: I can make this work currently by casting my tooltip with type any and setting it as the text prop.

giladgray commented 7 years ago

oh goodness we decided many moons ago against supporting tooltips on menus for several reasons:

  1. no other menu system does this. see OS X disabled menu items. they never have tooltips.
  2. menus are typically shown in Popovers, and tooltips are also Popovers. things can easily get weird when you nest Popovers, so we just avoid that composition when possible.
kmwhelan93 commented 7 years ago

Makes sense. Seems like a reasonable decision.

However, I noticed that iOS uses disabled menu items as headers for a menu, which is a different use case than mine. In my case, when someone is used to being able to do something, but cannot in this specific situation, they need some kind of explanation. To me, the cleanest way to present that information is with a hover. ex: screen shot 2017-03-31 at 3 25 21 pm

There also seems to be several other use cases with similar requests given responses in Slack.

Regardless, I'm happy with this being officially unsupported so long as it continues to be allowed in at least some way. For reference, here is how to get this working correctly at the moment. tooltip-in-menu

llorca commented 7 years ago

Glad there's a workaround for it. We'll keep this open for discussion but it's very low priority for us at the moment

ashleydavis commented 5 years ago

It's pretty important to be able to have tooltips on menu items.

The work around I'm using is to modify the display attribute on the popup target when it appears within a menu item:

.bp3-menu .bp3-popover-target {
    display: block;
}
giladgray commented 5 years ago

yes i've seen this use case a lot lately so i'm going to re-open to track implementing next year.

andrewtsun25 commented 3 years ago

hey guys! given Blueprint 3, I've found a workaround that could give Tooltips to MenuItem components without flickering and retaining original functionality as best as possible. only disadvantage here is overflow is not prevented.

<Tooltip
    modifiers={{
        flip: { enabled: false },
        preventOverflow: { enabled: false }
    }}
    content={"Your content here"}
    position={Position.RIGHT}
    className={styles.displayBlock}
    targetClassName={styles.fullWidth}
    >
        <MenuItem ... />
 </Tooltip>

where the styles are defined as:

.fullWidth {
    width: 100%;
}

.displayBlock {
    display: block;
}
DanHarman commented 2 years ago

This is a little more painful in Suggests etc. If you use MenuItems in the popup, if you wrap them in a tooltip, the scroll to selected item breaks. Not sure on cause yet.