Add a way to know the current 'open' state of tooltips #516

Closed
opened 2026-01-29 17:38:31 +00:00 by claunia · 4 comments
Owner

Originally created by @mwarvik on GitHub (Aug 22, 2022).

It would be nice to know the open state of tooltips. I can also try to create a PR, if this is something more people think is missing.

Is your feature request related to a problem? Please describe.
We are using tooltips on our page, with a click to open them. We would like to close them with a click on the same button, but that is not possible (as I see it) at the moment, as there is no way to know the state of the tooltip.

Describe the solution you'd like
Either add a flag to TooltipService to indicate if any tooltip is currently open, or invoke the OnClose event when the tooltip is closed (also when closed by clicking some other element).

Describe alternatives you've considered
I tried to make it work with the current implementation, but it's not possible as I see it.
Example:

  1. Add event handler to OnClose that sets a TooltipIsOpen flag to false.
  2. Click button to open tooltip (sets flag to true).
  3. Click outside the button (tooltip closes), event handler not called, TooltipIsOpen is still true.
  4. Click on button again, as the flag indicates it's still open, it will not open before a second click.

Additional context
Nothing to add.

Originally created by @mwarvik on GitHub (Aug 22, 2022). It would be nice to know the open state of tooltips. I can also try to create a PR, if this is something more people think is missing. **Is your feature request related to a problem? Please describe.** We are using tooltips on our page, with a click to open them. We would like to close them with a click on the same button, but that is not possible (as I see it) at the moment, as there is no way to know the state of the tooltip. **Describe the solution you'd like** Either add a flag to `TooltipService` to indicate if any tooltip is currently open, or invoke the `OnClose` event when the tooltip is closed (also when closed by clicking some other element). **Describe alternatives you've considered** I tried to make it work with the current implementation, but it's not possible as I see it. Example: 1. Add event handler to `OnClose` that sets a `TooltipIsOpen` flag to `false`. 1. Click button to open tooltip (sets flag to `true`). 3. Click outside the button (tooltip closes), event handler not called, `TooltipIsOpen` is still `true`. 3. Click on button again, as the flag indicates it's still open, it will not open before a second click. **Additional context** Nothing to add.
Author
Owner

@enchev commented on GitHub (Aug 22, 2022):

I believe that you can use a simple variable in your button click for such state.

@enchev commented on GitHub (Aug 22, 2022): I believe that you can use a simple variable in your button click for such state.
Author
Owner

@mwarvik commented on GitHub (Aug 22, 2022):

@enchev That would not work, if you read the example. The wrong state will be set if the tooltip is closed by clicking something else than the button.

@mwarvik commented on GitHub (Aug 22, 2022): @enchev That would not work, if you read the example. The wrong state will be set if the tooltip is closed by clicking something else than the button.
Author
Owner

@enchev commented on GitHub (Aug 22, 2022):

Maybe similar option can work for tooltip as well:
https://github.com/radzenhq/radzen-blazor/blob/master/Radzen.Blazor/DialogService.cs#L373

@enchev commented on GitHub (Aug 22, 2022): Maybe similar option can work for tooltip as well: https://github.com/radzenhq/radzen-blazor/blob/master/Radzen.Blazor/DialogService.cs#L373
Author
Owner

@mwarvik commented on GitHub (Aug 30, 2022):

Thank you! It works great :)

@mwarvik commented on GitHub (Aug 30, 2022): Thank you! It works great :)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/radzen-blazor#516