Skip to content

Commit 0bc4ad5

Browse files
authored
fix(accessibility): proper label for expand/collapse view (#288)
* fix(accessibility): proper label for expand/collapse view
1 parent c6409c1 commit 0bc4ad5

File tree

7 files changed

+85
-3
lines changed

7 files changed

+85
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1717

1818
- Fixed an issue where aria-hidden stayed true on hover for tooltips.
1919
- Fixed an issue where collected data wasn't synced properly after going back online from offline mode.
20+
- Fixed an accessibility issue with collapse/expand buttons.
2021

2122
## [2.2.4](https://github.com/InseeFr/stromae-dsfr/releases/tag/2.2.4) - 2025-11-25
2223

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "stromae-dsfr",
33
"private": true,
4-
"version": "2.3.1-rc.2",
4+
"version": "2.3.1-rc.expand-collapse-button",
55
"type": "module",
66
"scripts": {
77
"prepare": "husky && vite-envs update-types",

src/components/orchestrator/Orchestrator.test.tsx

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -746,4 +746,78 @@ describe('Orchestrator', () => {
746746
surveyUnitCompositeName: 'RnJhbsOnYWlz',
747747
})
748748
})
749+
750+
it('has proper label when expanding/collapsing layout', async () => {
751+
const user = userEvent.setup()
752+
753+
const sourceWithSequencePagination = {
754+
componentType: 'Questionnaire',
755+
components: [
756+
{
757+
componentType: 'Sequence',
758+
page: '1',
759+
id: 's1',
760+
label: [{ type: 'VTL', value: '"Ma séquence"' }],
761+
},
762+
{
763+
componentType: 'Question',
764+
page: '2',
765+
id: 'q1',
766+
components: [
767+
{
768+
componentType: 'Input',
769+
page: '2',
770+
label: { value: 'my-question', type: 'TXT' },
771+
id: 'i1',
772+
response: { name: 'my-question-input' },
773+
},
774+
],
775+
},
776+
{
777+
componentType: 'Question',
778+
page: '3',
779+
id: 'q2',
780+
components: [
781+
{
782+
componentType: 'Input',
783+
page: '3',
784+
label: { value: 'my-question-2', type: 'TXT' },
785+
id: 'i2',
786+
response: { name: 'my-question-2-input' },
787+
},
788+
],
789+
},
790+
],
791+
variables: [],
792+
maxPage: '3',
793+
pagination: 'sequence' as const,
794+
}
795+
796+
const interrogationWithLunaticPage = {
797+
...defaultInterrogation,
798+
stateData: {
799+
state: 'INIT' as QuestionnaireState,
800+
date: 0,
801+
currentPage: '1' as PageType,
802+
},
803+
}
804+
805+
const { getByText, getByRole } = renderWithRouter(
806+
<OrchestratorTestWrapper
807+
mode={MODE_TYPE.COLLECT}
808+
source={sourceWithSequencePagination}
809+
initialInterrogation={interrogationWithLunaticPage}
810+
/>,
811+
)
812+
813+
await user.click(getByText('Start'))
814+
const collapseButton = getByRole('button', { name: 'Collapse view' })
815+
expect(collapseButton).toBeInTheDocument()
816+
expect(collapseButton).toHaveAttribute('aria-pressed', 'true')
817+
818+
await user.click(collapseButton)
819+
const expandButton = getByRole('button', { name: 'Expand view' })
820+
expect(expandButton).toBeInTheDocument()
821+
expect(expandButton).toHaveAttribute('aria-pressed', 'false')
822+
})
749823
})

src/components/orchestrator/SurveyContainer.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,10 @@ export function SurveyContainer(
108108
}
109109
priority="tertiary"
110110
onClick={() => setIsLayoutExpanded((expanded) => !expanded)}
111-
title={t('button expand')}
111+
title={
112+
isLayoutExpanded ? t('button collapse') : t('button expand')
113+
}
114+
aria-pressed={isLayoutExpanded}
112115
/>
113116
</div>
114117
)}
@@ -175,6 +178,7 @@ const { i18n } = declareComponentKeys<
175178
| 'button previous title'
176179
| 'button previous label'
177180
| 'button expand'
181+
| 'button collapse'
178182
| {
179183
K: 'button continue title'
180184
P: { currentPage: InternalPageType }

src/i18n/resources/en.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ export const translations: Translations<'en'> = {
123123
'button download data': 'Download data',
124124
'button download articulation': 'Download roundabout recap',
125125
'button expand': 'Expand view',
126+
'button collapse': 'Collapse view',
126127
'button previous title': 'Return to the previous step',
127128
'button previous label': 'Previous',
128129
},

src/i18n/resources/fr.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@ export const translations: Translations<'fr'> = {
128128
'button download articulation':
129129
'Télécharger le récapitulatif du rond-point',
130130

131-
'button expand': 'Étendre la vue',
131+
'button expand': "Étendre l'affichage",
132+
'button collapse': "Réduire l'affichage",
132133

133134
'button previous title': "Revenir à l'étape précédente",
134135
'button previous label': 'Précédent',

src/i18n/resources/sq.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ export const translations: Translations<'sq'> = {
123123
'button download data': 'Shkarko të dhënat',
124124
'button download articulation': 'Shkarko tabelën e artikulimit',
125125
'button expand': 'Zgjero pamjen',
126+
'button collapse': 'Tkurr pamjen',
126127
'button previous title': 'Kthehu në hapin e mëparshëm',
127128
'button previous label': 'I mëparshmi',
128129
},

0 commit comments

Comments
 (0)