You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[EuiTooltip] Add logic to close all tooltips before showing another EuiTooltip instance #6423
@jughosta reached out to the EUI team for a way to prevent tooltips persisting on the screen after click events. This issue is being tracked in Kibana #144482.
The EUI team proposed a UX solution where we prevent two tooltips being present in the DOM. If a user toggles a tooltip, we should check for any tooltips present, close them, then reveal the new tooltip.
@constancecchen has proposed an enhancement using React.Context:
A new context/provider within EuiProvider just for tooltips, similar to how we have CurrentEuiBreakpointProvider now.
I'd recommend a singleton to track & enforce the one active tooltip rule, instead of needing context to be set & communicating through that. Essentially, the same service/logic that would come from context becomes a JS import (or lives in tool_tip.tsx directly),
import { registerTooltip, deregisterTooltip } from 'tooltip_logic';
...
showTooltip = () => {
... existing logic ...
registerTooltip(this.hideToolTip); // tell the service a new tooltip is active, provides a callback function for the service to close the tooltip if another one becomes active; if there is already an active tooltip, this call to registerTooltip will dismiss it
}
hideToolTip = () => {
... existing logic ...
deregisterTooltip(this.hideToolTip);
}
Interesting - I'm not entirely sure I see how a singleton would function correctly with the state updates needed to determine individual tooltip visibility. Do you have a POC or codesandbox to demonstrate?
Activity
chandlerprall commentedon Nov 29, 2022
I'd recommend a singleton to track & enforce the one active tooltip rule, instead of needing context to be set & communicating through that. Essentially, the same service/logic that would come from context becomes a JS import (or lives in tool_tip.tsx directly),
cee-chen commentedon Nov 29, 2022
Interesting - I'm not entirely sure I see how a singleton would function correctly with the state updates needed to determine individual tooltip visibility. Do you have a POC or codesandbox to demonstrate?