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

(PC-33975)[PRO] feat: Replace adage multiselect placeholderw with ind… #15849

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,9 @@ export const OfferFilters = ({
title="Choisir un département"
>
<AdageMultiselect
placeholder="Ex: 59 ou Hauts-de-France"
indication="Par exemple : 59 ou Hauts-de-France"
name="departments"
label="Départements"
label="Rechercher un département"
options={departmentOptions}
isOpen={modalOpenStatus['localisation']}
/>
Expand All @@ -291,9 +291,9 @@ export const OfferFilters = ({
title="Choisir une académie"
>
<AdageMultiselect
placeholder="Ex: Nantes"
indication="Par exemple : Nantes"
name="academies"
label="Académies"
label="Rechercher une académie"
options={academiesOptions}
isOpen={modalOpenStatus['localisation']}
/>
Expand Down Expand Up @@ -336,9 +336,9 @@ export const OfferFilters = ({
title="Choisir un domaine artistique"
>
<AdageMultiselect
placeholder="Ex: Cinéma"
indication="Par exemple : Cinéma"
name="domains"
label="Domaine artistique"
label="Rechercher un domaine artistique"
options={domainsOptions}
isOpen={modalOpenStatus['domains']}
/>
Expand All @@ -360,9 +360,9 @@ export const OfferFilters = ({
title="Choisir un format"
>
<AdageMultiselect
placeholder="Ex: Représentation"
indication="Par exemple : Représentation"
name="formats"
label="Format"
label="Rechercher un format"
options={formatsOptions}
isOpen={modalOpenStatus['formats']}
/>
Expand All @@ -381,12 +381,12 @@ export const OfferFilters = ({
<ModalFilterLayout
onClean={() => onReset('students', [])}
onSearch={() => onSearch('students')}
title="Pour quel niveau scolaire ?"
title="Choisir un niveau scolaire"
>
<AdageMultiselect
placeholder="Ex: Collège"
indication="Par exemple : Collège"
name="students"
label="Niveau scolaire"
label="Rechercher un niveau scolaire"
options={studentsOptionsFiltered}
isOpen={modalOpenStatus['students']}
sortOptions={(options, selectedOptions) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,13 @@ describe('OfferFilters', () => {
renderOfferFilters(initialValues, LocalisationFilterStates.DEPARTMENTS)

expect(
screen.getByPlaceholderText('Ex: 59 ou Hauts-de-France')
screen.getByText('Par exemple : 59 ou Hauts-de-France')
).toBeInTheDocument()
})
it('should display academies options in localisation filter modal', () => {
renderOfferFilters(initialValues, LocalisationFilterStates.ACADEMIES)

expect(screen.getByPlaceholderText('Ex: Nantes')).toBeInTheDocument()
expect(screen.getByText('Par exemple : Nantes')).toBeInTheDocument()
})

it('should display radius range input in localisation filter modal', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ describe('offersSearch component', () => {

// Then
expect(
screen.getByPlaceholderText('Ex: 59 ou Hauts-de-France')
screen.getByText('Par exemple : 59 ou Hauts-de-France')
).toBeInTheDocument()
})

Expand Down Expand Up @@ -288,7 +288,7 @@ describe('offersSearch component', () => {
)

// Then
expect(screen.getByPlaceholderText('Ex: Nantes')).toBeInTheDocument()
expect(screen.getByText('Par exemple : Nantes')).toBeInTheDocument()
})

it('should display radius input filter if user has selected around me filter', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
.container {
display: flex;
flex-direction: column;
gap: rem.torem(18px);
height: rem.torem(250px);
}

Expand All @@ -17,17 +16,13 @@
max-height: rem.torem(400px);
overflow-y: scroll;
padding: rem.torem(8px) 0 0 rem.torem(8px);
margin-top: rem.torem(18px);

li:last-child {
margin-bottom: rem.torem(20px);
}
}

.search-input {
@include forms.input-theme;
@include forms.input-theme-nested;
}

input[type="search"]::-webkit-search-cancel-button {
appearance: none;
width: rem.torem(20px);
Expand All @@ -43,3 +38,9 @@ input[type="search"]::-webkit-search-cancel-button {
.visually-hidden {
@include a11y.visually-hidden;
}

.search-indication {
@include fonts.body-xs;

color: var(--color-grey-dark);
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const options = [
export const Default: StoryObj<typeof AdageMultiselect> = {
args: {
options,
placeholder: 'Ex: Théâtre',
indication: 'Ex: Théâtre',
name: 'educationalDomains',
label: 'Rechercher un domaine artistique',
isOpen: true,
Expand Down
14 changes: 10 additions & 4 deletions pro/src/ui-kit/form/AdageMultiselect/AdageMultiselect.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { useCombobox } from 'downshift'
import { useField, useFormikContext } from 'formik'
import { useEffect, useState } from 'react'
import { useEffect, useId, useState } from 'react'

import strokeSearch from 'icons/stroke-search.svg'
import { BaseCheckbox } from 'ui-kit/form/shared/BaseCheckbox/BaseCheckbox'

import { BaseInput } from '../shared/BaseInput/BaseInput'
Expand All @@ -15,7 +16,7 @@ export interface ItemProps {

interface AdageMultiselectProps {
options: ItemProps[]
placeholder: string
indication: string
name: string
label: string
isOpen: boolean
Expand Down Expand Up @@ -74,7 +75,7 @@ const isIncluded = (

export const AdageMultiselect = ({
options,
placeholder,
indication,
name,
label,
isOpen,
Expand All @@ -86,6 +87,7 @@ export const AdageMultiselect = ({
const [field] = useField<ItemProps['value'][]>(name)
const { setFieldValue } = useFormikContext<any>()
const [sortedOptions, setSortedOptions] = useState<ItemProps[]>([])
const indicationId = useId()

const {
getLabelProps,
Expand Down Expand Up @@ -160,11 +162,15 @@ export const AdageMultiselect = ({
type="search"
name="search"
className={styles['search-input']}
placeholder={placeholder}
maxLength={filterMaxLength}
value={inputValue}
aria-describedby={indicationId}
leftIcon={strokeSearch}
{...getInputProps()}
/>
<p className={styles['search-indication']} id={indicationId}>
{indication}
</p>
<ul
className={styles['search-list']}
{...getMenuProps({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const renderAdageMultiselect = (
>
<AdageMultiselect
options={customOptions}
placeholder="Ex: Théâtre"
indication="Ex: Théâtre"
name="educationalDomains"
label="Rechercher un domaine artistique"
isOpen={true}
Expand All @@ -37,7 +37,7 @@ describe('AdageMultiselect', () => {
it('should filter options when user type in input', async () => {
renderAdageMultiselect()

const input = screen.getByPlaceholderText('Ex: Théâtre')
const input = screen.getByRole('combobox')
await userEvent.type(input, 'Th')

expect(screen.getByText('Théatre')).toBeInTheDocument()
Expand Down Expand Up @@ -69,7 +69,7 @@ describe('AdageMultiselect', () => {
it('should display all options when user erase input value', async () => {
renderAdageMultiselect()

const input = screen.getByPlaceholderText('Ex: Théâtre')
const input = screen.getByRole('combobox')

await userEvent.type(input, 'Th')

Expand Down
Loading