Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(DsfrInput): 🐛 Corrige la typo sur l'attribut aria-describedby #600

Merged
merged 1 commit into from
Sep 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading