Skip to content

Commit

Permalink
chore: 🎨 améliore le code de DsfrMultiselect
Browse files Browse the repository at this point in the history
  • Loading branch information
laruiss committed Oct 31, 2024
1 parent e2e6450 commit 469c60b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/components/DsfrMultiselect/DsfrMultiselect.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { fireEvent, render } from '@testing-library/vue'

import DsfrMultiselect from './DsfrMultiselect.vue'

describe('DsfrMultiselect', () => {
Expand Down
16 changes: 10 additions & 6 deletions src/components/DsfrMultiselect/DsfrMultiselect.vue
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
<script lang="ts" setup generic="T extends Object | string | number">
import { getRandomId } from '@/utils/random-utils'
import { computed, onUnmounted, ref } from 'vue'
import { useCollapsable } from '../../composables'
import DsfrButton from '../DsfrButton/DsfrButton.vue'
import DsfrCheckbox from '../DsfrCheckbox/DsfrCheckbox.vue'
import DsfrFieldset from '../DsfrFieldset/DsfrFieldset.vue'
import DsfrInput from '../DsfrInput/DsfrInput.vue'
import type { DsfrMultiSelectProps, DsfrMultiSelectSlots } from './DsfrMultiselect.types'
import { getRandomId } from '@/utils/random-utils'
const props = withDefaults(
defineProps<DsfrMultiSelectProps<T>>(),
{
Expand Down Expand Up @@ -285,10 +286,13 @@ onUnmounted(() => {
const defaultButtonLabel = computed(() => {
const nbElements = model.value?.length
if (nbElements === 0) {
const noElements = nbElements === 0
const severalElements = nbElements > 1
if (noElements) {
return 'Sélectionner une option'
}
return `${nbElements} option${nbElements > 1 ? 's' : ''} sélectionnée${nbElements > 1 ? 's' : ''}`
return `${nbElements} option${severalElements ? 's' : ''} sélectionnée${severalElements ? 's' : ''}`
})
const finalLabelClass = computed(() => [
Expand Down Expand Up @@ -507,14 +511,14 @@ const finalLabelClass = computed(() => [
}
.fr-multiselect__collapse {
z-index: 20000;
z-index: 1;
position: absolute;
transform-origin: left top;
width: var(--width-host);
left: var(--left-position);
top: var(--top-position);
padding: 1rem;
margin-top: 4px;
margin-top: 0.5rem;
background-color: var(--background-overlap-grey);
filter: drop-shadow(var(--overlap-shadow));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<script setup lang="ts">
import { computed, ref } from 'vue'
import DsfrMultiselect from '../DsfrMultiselect.vue'
const options = [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<script setup lang="ts">
import { ref } from 'vue'
import DsfrMultiselect from '../DsfrMultiselect.vue'
const options = [
Expand Down

0 comments on commit 469c60b

Please sign in to comment.