fix(frontend): use-tooltip の呼び出し元の UI が無くなったら自動的に削除されるようにする (#11949)
* Update use-tooltip.ts * Update CHANGELOG.md
This commit is contained in:
@@ -21,6 +21,8 @@ export function useTooltip(
|
||||
|
||||
let changeShowingState: (() => void) | null;
|
||||
|
||||
let autoHidingTimer;
|
||||
|
||||
const open = () => {
|
||||
close();
|
||||
if (!isHovering) return;
|
||||
@@ -33,6 +35,16 @@ export function useTooltip(
|
||||
changeShowingState = () => {
|
||||
showing.value = false;
|
||||
};
|
||||
|
||||
autoHidingTimer = window.setInterval(() => {
|
||||
if (!document.body.contains(elRef.value)) {
|
||||
if (!isHovering) return;
|
||||
isHovering = false;
|
||||
window.clearTimeout(timeoutId);
|
||||
close();
|
||||
window.clearInterval(autoHidingTimer);
|
||||
}
|
||||
}, 1000);
|
||||
};
|
||||
|
||||
const close = () => {
|
||||
@@ -53,6 +65,7 @@ export function useTooltip(
|
||||
if (!isHovering) return;
|
||||
isHovering = false;
|
||||
window.clearTimeout(timeoutId);
|
||||
window.clearInterval(autoHidingTimer);
|
||||
close();
|
||||
};
|
||||
|
||||
@@ -67,6 +80,7 @@ export function useTooltip(
|
||||
if (!isHovering) return;
|
||||
isHovering = false;
|
||||
window.clearTimeout(timeoutId);
|
||||
window.clearInterval(autoHidingTimer);
|
||||
close();
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user