mirror of
https://github.com/zadam/trilium.git
synced 2025-12-08 08:24:24 +01:00
fix(react): duplicate tooltips on focus vs hover
This commit is contained in:
parent
6e8f8ea357
commit
b99d4532df
@ -633,6 +633,8 @@ export function useTooltip(elRef: RefObject<HTMLElement>, config: Partial<Toolti
|
|||||||
return { showTooltip, hideTooltip };
|
return { showTooltip, hideTooltip };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let tooltips = new Set<Tooltip>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Similar to {@link useTooltip}, but doesn't expose methods to imperatively hide or show the tooltip.
|
* Similar to {@link useTooltip}, but doesn't expose methods to imperatively hide or show the tooltip.
|
||||||
*
|
*
|
||||||
@ -645,7 +647,17 @@ export function useStaticTooltip(elRef: RefObject<Element>, config?: Partial<Too
|
|||||||
if (!elRef?.current || !hasTooltip) return;
|
if (!elRef?.current || !hasTooltip) return;
|
||||||
|
|
||||||
const tooltip = Tooltip.getOrCreateInstance(elRef.current, config);
|
const tooltip = Tooltip.getOrCreateInstance(elRef.current, config);
|
||||||
|
elRef.current.addEventListener("show.bs.tooltip", () => {
|
||||||
|
// Hide all the other tooltips.
|
||||||
|
for (const otherTooltip of tooltips) {
|
||||||
|
if (otherTooltip === tooltip) continue;
|
||||||
|
otherTooltip.hide();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
tooltips.add(tooltip);
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
|
tooltips.delete(tooltip);
|
||||||
tooltip.dispose();
|
tooltip.dispose();
|
||||||
// workaround for https://github.com/twbs/bootstrap/issues/37474
|
// workaround for https://github.com/twbs/bootstrap/issues/37474
|
||||||
(tooltip as any)._activeTrigger = {};
|
(tooltip as any)._activeTrigger = {};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user