fix(frontend): use-tooltip の呼び出し元の UI が無くなったら自動的に削除されるようにする (#11949)
* Update use-tooltip.ts * Update CHANGELOG.md
This commit is contained in:
parent
6840434661
commit
e00fdc2d59
2 changed files with 15 additions and 0 deletions
|
@ -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();
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue