Skip to content

Commit

Permalink
a11y: les menus d'actions sont tabulables, refermables au clavier
Browse files Browse the repository at this point in the history
  • Loading branch information
thom4parisot committed May 21, 2024
1 parent 51adfdd commit 6e649d3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
14 changes: 9 additions & 5 deletions src/components/ActionDropdown.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup>
import { onUpdated, ref, watch } from "vue"
import { onClickOutside, useSwipe } from "@vueuse/core"
import { onBeforeUnmount, onUpdated, ref, watch } from "vue"
import { onClickOutside, onKeyStroke, useSwipe } from "@vueuse/core"
import { useHead } from "@unhead/vue"
const show = ref(false)
Expand Down Expand Up @@ -45,8 +45,12 @@ const { direction, lengthY } = useSwipe(
}
)
onClickOutside(actionsMenuRef, () => {
show.value = false
const cancelKeyStroke = onKeyStroke('Escape', () => show.value = false)
const cancelClickOutside = onClickOutside(actionsMenuRef, () => show.value = false)
onBeforeUnmount(() => {
cancelClickOutside()
cancelKeyStroke()
})
watch(show, (value) => {
Expand Down Expand Up @@ -79,7 +83,7 @@ watch(show, (value) => {
Autres actions
</button>
</slot>
<dialog class="menu-container" :open="show">
<dialog class="menu-container" :open="show" tabindex="-1">
<div class="fr-menu" :class="{ '--fade-in': fadeIn }" ref="actionsMenuRef" :style="{ '--down': down }">
<ul class="fr-menu__list fr-btns-group" :class="{ 'fr-btns-group--icon-left': props.withIcons }">
<slot/>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Features/MassActionsSelector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<template #trigger="{ toggle }">
<button
class="fr-btn fr-btn--sm fr-btn--secondary fr-btn--icon-right fr-icon-arrow-down-s-line menu-button"
@click="toggle"
@click.stop.prevent="toggle"
:disabled="!isOnline"
>
{{ label }}
Expand Down

0 comments on commit 6e649d3

Please sign in to comment.