Skip to content

Commit

Permalink
Merge pull request #600 from WilliamDASILVA/fix/aria-describedby
Browse files Browse the repository at this point in the history
fix(DsfrInput): 🐛 Corrige la typo sur l'attribut aria-describedby
  • Loading branch information
laruiss authored Sep 4, 2023
2 parents f8409b9 + 566d5c9 commit 1b5f205
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
31 changes: 29 additions & 2 deletions src/components/DsfrInput/DsfrInput.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ describe('DsfrInput', () => {

// When
const { getByText } = render(DsfrInput, {
stubs: ['v-icon'],
props: {
labelVisible,
label,
Expand All @@ -29,7 +28,6 @@ describe('DsfrInput', () => {

// When
const { getByText } = render(DsfrInput, {
stubs: ['v-icon'],
props: {
labelVisible,
label,
Expand All @@ -40,4 +38,33 @@ describe('DsfrInput', () => {
expect(getByText(label)).toHaveClass('fr-label')
expect(getByText(label)).toHaveClass('invisible')
})

it('should render DsfrInput with proper aria-describedby attribute if descriptionId is provided', () => {
// Given
const descriptionId = 'labelId'

// When
const { container } = render(DsfrInput, {
props: {
descriptionId,
},
})

// Then
const inputNode = container.querySelector('input')
expect(inputNode).toHaveAttribute('aria-describedby', 'labelId')
})

it('should render DsfrInput without any aria-describedby attribute if descriptionId not provided', () => {
// When
const { container } = render(DsfrInput, {
props: {
descriptionId: undefined,
},
})

// Then
const inputNode = container.querySelector('input')
expect(inputNode).not.toHaveAttribute('aria-describedby')
})
})
4 changes: 2 additions & 2 deletions src/components/DsfrInput/DsfrInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ defineExpose({
'fr-input--valid': isValid,
}"
:value="modelValue"
:aria-aria-describedby="descriptionId || undefined"
:aria-describedby="descriptionId || undefined"
@input="$emit('update:modelValue', $event.target.value)"
/>

Expand All @@ -104,7 +104,7 @@ defineExpose({
'fr-input--valid': isValid,
}"
:value="modelValue"
:aria-aria-describedby="descriptionId || undefined"
:aria-describedby="descriptionId || undefined"
@input="$emit('update:modelValue', $event.target.value)"
/>
</div>
Expand Down

0 comments on commit 1b5f205

Please sign in to comment.