Skip to content

Commit

Permalink
Merge pull request #955 from dnum-mi/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
laruiss authored Oct 3, 2024
2 parents d871345 + bb4d8d4 commit 84b6de9
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/components/DsfrTooltip/DsfrTooltip.vue
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,20 @@ const clickListener = (event: MouseEvent) => {
show.value = false
}
const onEscapeKey = (event: KeyboardEvent) => {
if (event.key === 'Escape') {
show.value = false
}
}
onMounted(() => {
document.documentElement.addEventListener('click', clickListener)
document.documentElement.addEventListener('keydown', onEscapeKey)
})
onUnmounted(() => {
document.documentElement.removeEventListener('click', clickListener)
document.documentElement.removeEventListener('keydown', onEscapeKey)
})
const onMouseEnter = () => {
Expand Down Expand Up @@ -124,9 +132,11 @@ const onClick = () => {
:class="onHover ? 'fr-link' : 'fr-btn fr-btn--tooltip'"
:aria-describedby="id"
:href="onHover ? '#' : undefined"
@click="onClick()"
@click.stop="onClick()"
@mouseenter="onMouseEnter()"
@mouseleave="onMouseLeave()"
@focus="onMouseEnter()"
@blur="onMouseLeave()"
>
<!-- @slot Slot par défaut pour le contenu de l’infobulle -->
<slot />
Expand Down

0 comments on commit 84b6de9

Please sign in to comment.