Skip to content

Commit fd1e811

Browse files
authored
Merge pull request #1119 from dnum-mi/1118-dsfr-select-required
fix(DsfrSelect): 🐛 empêche soumission formulaire si required
2 parents 1e9ac53 + 0f94003 commit fd1e811

File tree

3 files changed

+24
-6
lines changed

3 files changed

+24
-6
lines changed

demo-app/views/AppForm.vue

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { ref } from 'vue'
44
import DsfrAlert from '@/components/DsfrAlert/DsfrAlert.vue'
55
import DsfrButton from '@/components/DsfrButton/DsfrButton.vue'
66
import DsfrCheckboxSet from '@/components/DsfrCheckbox/DsfrCheckboxSet.vue'
7+
import DsfrSelect from '@/components/DsfrSelect/DsfrSelect.vue'
78
import DsfrFileUpload from '@/components/DsfrFileUpload/DsfrFileUpload.vue'
89
import DsfrRadioButtonSet from '@/components/DsfrRadioButton/DsfrRadioButtonSet.vue'
910
import type { DsfrCheckboxSetProps } from '@/components/DsfrCheckbox/DsfrCheckbox.types'
@@ -21,8 +22,15 @@ const sendFile = () => {
2122
console.log('filesToUpload:', filesToUpload.value) // eslint-disable-line no-console
2223
}
2324
25+
const isGood = ref<boolean>()
2426
const whatever = ref('')
2527
const radioTest = ref('')
28+
const radioTest2 = ref('')
29+
30+
const options = [
31+
{ value: true, text: 'Oui', disabled: false },
32+
{ value: false, text: 'Non', disabled: false },
33+
]
2634
2735
const selectedCheckbox = ref(false)
2836
const selectedCheckboxes = ref([])
@@ -77,16 +85,16 @@ const cbOptions: DsfrCheckboxSetProps['options'] = [
7785
]"
7886
/>
7987
<DsfrRadioButtonSet
80-
v-model="radioTest"
81-
name="radio-123aui"
88+
v-model="radioTest2"
89+
name="radio-123auie"
8290
:options="[
8391
{
84-
label: 'label 1',
92+
label: 'label 2.1',
8593
value: 1,
8694
required: true,
8795
},
8896
{
89-
label: 'label 2',
97+
label: 'label 2.2',
9098
value: 2,
9199
},
92100
]"
@@ -97,6 +105,13 @@ const cbOptions: DsfrCheckboxSetProps['options'] = [
97105
</DsfrRadioButtonSet>
98106
</div>
99107

108+
<DsfrSelect
109+
v-model="isGood"
110+
required
111+
label="Est-ce que c’est bon ?"
112+
:options
113+
/>
114+
100115
<DsfrButton
101116
type="submit"
102117
label="Bouton de soumission du formulaire"

demo-app/views/AppHome.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,8 @@ const rows = [
182182
<div class="flex justify-between items-center gap-2 w-full relative">
183183
<DsfrTooltip
184184
on-hover
185+
title="Titre"
186+
aria-label="Le libellé"
185187
content="Texte de l’info-bulle qui apparaît au survol"
186188
>
187189
Au survol

src/components/DsfrSelect/DsfrSelect.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,10 @@ const messageType = computed(() => {
7979
@change="$emit('update:modelValue', ($event.target as HTMLInputElement)?.value)"
8080
>
8181
<option
82-
:selected="!options.some(option => typeof option !== 'object' || option === null ? option === modelValue : option.value === modelValue)"
82+
:selected="!options.some(option => (typeof option !== 'object' || option === null) ? option === modelValue : option.value === modelValue)"
8383
disabled
84-
hidden
84+
value=""
85+
hidden=""
8586
>
8687
{{ defaultUnselectedText }}
8788
</option>

0 commit comments

Comments
 (0)