Skip to content

Commit

Permalink
fix(frontend): ツールチップが永久にDOMに残ることがある問題を修正
Browse files Browse the repository at this point in the history
  • Loading branch information
syuilo committed May 15, 2023
1 parent f4e6d73 commit 60f504b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
3 changes: 3 additions & 0 deletions packages/frontend/src/components/MkTooltip.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ const emit = defineEmits<{
(ev: 'closed'): void;
}>();
// タイミングによっては最初から showing = false な場合があり、その場合に closed 扱いにしないと永久にDOMに残ることになる
if (!props.showing) emit('closed');
const el = shallowRef<HTMLElement>();
const zIndex = os.claimZIndex('high');
Expand Down
16 changes: 12 additions & 4 deletions packages/frontend/src/directives/tooltip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { defineAsyncComponent, Directive, ref } from 'vue';
import { isTouchUsing } from '@/scripts/touch';
import { popup, alert } from '@/os';

const start = isTouchUsing ? 'touchstart' : 'mouseover';
const start = isTouchUsing ? 'touchstart' : 'mouseenter';
const end = isTouchUsing ? 'touchend' : 'mouseleave';

export default {
Expand Down Expand Up @@ -63,16 +63,24 @@ export default {
ev.preventDefault();
});

el.addEventListener(start, () => {
el.addEventListener(start, (ev) => {
window.clearTimeout(self.showTimer);
window.clearTimeout(self.hideTimer);
self.showTimer = window.setTimeout(self.show, delay);
if (delay === 0) {
self.show();
} else {
self.showTimer = window.setTimeout(self.show, delay);
}
}, { passive: true });

el.addEventListener(end, () => {
window.clearTimeout(self.showTimer);
window.clearTimeout(self.hideTimer);
self.hideTimer = window.setTimeout(self.close, delay);
if (delay === 0) {
self.close();
} else {
self.hideTimer = window.setTimeout(self.close, delay);
}
}, { passive: true });

el.addEventListener('click', () => {
Expand Down

1 comment on commit 60f504b

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Chromatic detects changes. Please review the changes on Chromatic.

Please sign in to comment.