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

Make hcTooltip support conditional expressions #2079

Closed
isaaclyman opened this issue Mar 10, 2023 · 4 comments · Fixed by #2094
Closed

Make hcTooltip support conditional expressions #2079

isaaclyman opened this issue Mar 10, 2023 · 4 comments · Fixed by #2094
Assignees
Labels
enhancement new minor version number to the library released

Comments

@isaaclyman
Copy link
Contributor

isaaclyman commented Mar 10, 2023

Describe your idea

It would be cool if [hcTooltip] could be conditionally rendered.

What problem are you trying to solve?

We have situations where a tooltip is needed in some states but not others. It's natural to try to do:

[hcTooltip]="shouldShowTooltip ? 'You can't do that right now.' : null"

Or

[hcTooltip]="shouldShowTooltip ? 'You can't do that right now.' : undefined"

But in both cases, an empty tooltip is still shown (see below). It would be great if the tooltip only showed when there was content in it.

Additional context

image

@bskeen
Copy link
Collaborator

bskeen commented Mar 10, 2023

Note: This is possible currently by binding to the [trigger] property on the HcPopoverAnchorDirective (that is how it is handled in the Instance Switcher in Cashmere, see below).

[hcTooltip]="_tooltipText.addText"
[trigger]="_tooltipText.addTrigger"

this._tooltipText = {
...toolTipVal,
addTrigger: toolTipVal.addText ? 'hover' : 'none',
closeTrigger: toolTipVal.closeText ? 'hover' : 'none'

@isaaclyman
Copy link
Contributor Author

Oh, brilliant. I'll use that as a workaround for now.

@andrew-frueh
Copy link
Collaborator

Yup, you nailed it @bskeen - using trigger that way is exactly how I do conditional tooltips or popovers. I do like your suggestion though @isaaclyman - would be cleaner code if you could get the same functionality with one line rather than having to set it in two places.

@andrew-frueh andrew-frueh self-assigned this Mar 13, 2023
@andrew-frueh andrew-frueh added the enhancement new minor version number to the library label Mar 13, 2023
andrew-frueh added a commit to andrew-frueh/Fabric.Cashmere that referenced this issue Mar 24, 2023
change trigger to none for tooltips with empty content

closes HealthCatalyst#2079
@health-catalyst
Copy link
Contributor

🎉 This issue has been resolved in version 14.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement new minor version number to the library released
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants