Skip to content

Commit

Permalink
fix: 🐛 DsfrAccordion shouldn't focus on toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
Trystan EVENO committed Jan 6, 2025
1 parent 236d118 commit e515ec9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/components/DsfrAccordion/DsfrAccordion.vue
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ watch(isActive, (newValue, oldValue) => {
'fr-collapse--expanded': cssExpanded, // Need to use a separate data to add/remove the class after a RAF
'fr-collapsing': collapsing,
}"
@transitionend="onTransitionEnd(isActive)"
@transitionend="onTransitionEnd(isActive, false)"
>
<!-- @slot Slot par dĂ©faut pour le contenu de l’accordĂ©on: sera dans `<div class="fr-collapse">` -->
<slot />
Expand Down
9 changes: 6 additions & 3 deletions src/composables/useCollapsable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,16 @@ export const useCollapsable = () => {
}

/**
* @see https://github.com/GouvernementFR/dsfr/blob/main/src/core/script/collapse/collapse.js#L25
* @see https://github.com/GouvernementFR/dsfr/blob/main/src/dsfr/core/script/collapse/collapse.js#L25
* @param {boolean} expanded
* @param {boolean} focusFirstAnchor
* @return void
*/
const onTransitionEnd = (expanded: boolean): void => {
const onTransitionEnd = (expanded: boolean, focusFirstAnchor: boolean = true): void => {
collapsing.value = false
collapse.value?.querySelector('a')?.focus()
if (focusFirstAnchor) {
collapse.value?.querySelector('a')?.focus()
}
if (collapse.value && expanded === false) {
collapse.value.style.removeProperty('--collapse-max-height')
}
Expand Down

0 comments on commit e515ec9

Please # to comment.