Skip to content

Commit 1894058

Browse files
committed
chore: 🎨 améliore le code de DsfrMultiselect
1 parent e2e6450 commit 1894058

File tree

4 files changed

+13
-8
lines changed

4 files changed

+13
-8
lines changed

‎src/components/DsfrMultiselect/DsfrMultiselect.spec.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { fireEvent, render } from '@testing-library/vue'
2+
23
import DsfrMultiselect from './DsfrMultiselect.vue'
34

45
describe('DsfrMultiselect', () => {

‎src/components/DsfrMultiselect/DsfrMultiselect.vue‎

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
<script lang="ts" setup generic="T extends Object | string | number">
2-
import { getRandomId } from '@/utils/random-utils'
32
import { computed, onUnmounted, ref } from 'vue'
43
54
import { useCollapsable } from '../../composables'
65
import DsfrButton from '../DsfrButton/DsfrButton.vue'
76
import DsfrCheckbox from '../DsfrCheckbox/DsfrCheckbox.vue'
87
import DsfrFieldset from '../DsfrFieldset/DsfrFieldset.vue'
9-
108
import DsfrInput from '../DsfrInput/DsfrInput.vue'
9+
1110
import type { DsfrMultiSelectProps, DsfrMultiSelectSlots } from './DsfrMultiselect.types'
1211
12+
import { getRandomId } from '@/utils/random-utils'
13+
1314
const props = withDefaults(
1415
defineProps<DsfrMultiSelectProps<T>>(),
1516
{
@@ -285,10 +286,13 @@ onUnmounted(() => {
285286
286287
const defaultButtonLabel = computed(() => {
287288
const nbElements = model.value?.length
288-
if (nbElements === 0) {
289+
const noElements = nbElements === 0
290+
const severalElements = nbElements > 1
291+
292+
if (noElements) {
289293
return 'Sélectionner une option'
290294
}
291-
return `${nbElements} option${nbElements > 1 ? 's' : ''} sélectionnée${nbElements > 1 ? 's' : ''}`
295+
return `${nbElements} option${severalElements ? 's' : ''} sélectionnée${severalElements ? 's' : ''}`
292296
})
293297
294298
const finalLabelClass = computed(() => [
@@ -507,14 +511,12 @@ const finalLabelClass = computed(() => [
507511
}
508512
509513
.fr-multiselect__collapse {
510-
z-index: 20000;
514+
z-index: 1;
511515
position: absolute;
512516
transform-origin: left top;
513517
width: var(--width-host);
514-
left: var(--left-position);
515-
top: var(--top-position);
516518
padding: 1rem;
517-
margin-top: 4px;
519+
margin-top: 0.25rem;
518520
background-color: var(--background-overlap-grey);
519521
filter: drop-shadow(var(--overlap-shadow));
520522
}

‎src/components/DsfrMultiselect/docs-demo/DsfrMultiselectDemoComplexe.vue‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<script setup lang="ts">
22
import { computed, ref } from 'vue'
3+
34
import DsfrMultiselect from '../DsfrMultiselect.vue'
45
56
const options = [

‎src/components/DsfrMultiselect/docs-demo/DsfrMultiselectDemoSimple.vue‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<script setup lang="ts">
22
import { ref } from 'vue'
3+
34
import DsfrMultiselect from '../DsfrMultiselect.vue'
45
56
const options = [

0 commit comments

Comments
 (0)