Skip to content

Commit b43e0c6

Browse files
authored
Merge pull request #1129 from dnum-mi/fix/#1125-dsfr-input-group-with-disabled-value-false
Corrige l'activation de DsfrInputGroup quand la propriété disabled vaut false
2 parents afaff05 + fcf6d18 commit b43e0c6

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

src/components/DsfrInput/DsfrInputGroup.spec.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { render } from '@testing-library/vue'
33
import DsfrInputGroup from './DsfrInputGroup.vue'
44

55
describe('DsfrInputGroup', () => {
6-
it('should disabled DsfrInputGroup', () => {
6+
it('should disable DsfrInputGroup with disabled="true"', () => {
77
// Given
88
const descriptionId = 'my-id'
99
const inputGroupId = 'my-group-id'
@@ -26,6 +26,28 @@ describe('DsfrInputGroup', () => {
2626
expect(getByTestId(inputGroupId).querySelector('input')).toHaveProperty('disabled')
2727
})
2828

29+
it('should not disable DsfrInputGroup with disabled="false"', () => {
30+
// Given
31+
const descriptionId = 'my-id'
32+
const inputGroupId = 'my-group-id'
33+
const disabled = false
34+
35+
// When
36+
const { getByTestId } = render(DsfrInputGroup, {
37+
stubs: ['v-icon'],
38+
props: {
39+
descriptionId,
40+
inputGroupId,
41+
disabled,
42+
},
43+
})
44+
45+
// Then
46+
47+
expect(getByTestId(inputGroupId)).not.toHaveClass('fr-input-group--disabled')
48+
expect(getByTestId(inputGroupId).querySelector('input')).toHaveProperty('disabled', false)
49+
})
50+
2951
it('should render DsfrInputGroup with error message', () => {
3052
// Given
3153
const errorMessage = 'my error message'

src/components/DsfrInput/DsfrInputGroup.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ const descId = computed(() => {
5656
class="fr-input-group"
5757
:class="[
5858
{
59-
'fr-input-group--disabled': 'disabled' in $attrs,
59+
'fr-input-group--disabled': 'disabled' in $attrs && $attrs.disabled !== false && $attrs.disabled !== undefined,
6060
'fr-input-group--error': errorMessage,
6161
'fr-input-group--valid': (validMessage && !errorMessage),
6262
},

src/composables/useCollapsable.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export const useCollapsable = () => {
5050
/**
5151
* @see https://github.com/GouvernementFR/dsfr/blob/main/src/dsfr/core/script/collapse/collapse.js#L25
5252
* @param {boolean} expanded
53-
* @param {boolean} focusFirstAnchor
53+
* @param {boolean} autoFocus
5454
* @return void
5555
*/
5656
const onTransitionEnd = (expanded: boolean, autoFocus = true): void => {

0 commit comments

Comments
 (0)