Skip to content

Conversation

@ogermain-kronos
Copy link
Contributor

@ogermain-kronos ogermain-kronos commented Nov 24, 2025

https://equisoft.atlassian.net/browse/DS-1386

Cette PR vient ajouter le support des modes multiselect et readonly dans la composante combox. Ça inclut le support de l'ajout de valeurs custom en mode multiselect.

multiselect
https://github.com/user-attachments/assets/067b0477-8d6d-44b1-af25-9fb9a2b68641

allowCustomValues
https://github.com/user-attachments/assets/be5f5663-df5a-4f53-b768-9b8d87db9390

Les valeurs viennent se placer dans un input caché à part (comme pour le DropdownList):
image
<input type="hidden" data-testid="input" value="ski|bi|di|quebec">

readonly
image

disabled
image

Un effort a aussi été fait pour isoler certaines fonctions également utilisées dans la composante dropdown-list.

@github-actions
Copy link

Storybook for this build: https://ds.equisoft.io/pr-1310/

@github-actions
Copy link

Webapp for this build: https://ds.equisoft.io/pr-1310/webapp/

) : (
<Textbox {...sharedInputProps} ref={refs.setReference} />
)}
{inputValue !== '' && !disabled && !multiselect && (
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

J'ai décidé de ne pas afficher la bouton de clear en mode multiselect, pour pas risquer qu'un user le clique par erreur (en se mêlant avec le bouton remove d'un tag à proximité, par exemple).

/>
{inputValue !== '' && !disabled && (
{multiselect ? (
<TagInputContainer
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

En mode multiselect, on remplace l'input Textbox par un div TagInputContainer ayant un input MultiSelectInput comme enfant.

Ça permet de donner l'illusion d'avoir un seul élément HTML pouvant accommoder à la fois les tags et les entrées écrites du user, et pouvant se redimensionner verticalement lorsque la largeur de l'ensemble des options sélectionnées (tags) dépassent la largeur du div.

<MultiSelectInput
{...sharedInputProps}
$hasTags={selectedOptions.length > 0}
ref={multiSelectInputRef}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Les refs et le focus sont sur le div par défaut, et on switch le focus vers l'input même lors de certains events (e.g. le onBlur, etc.) question de ne pas changer le comportement aux yeux du user à comparé au mode non-multiselect.

options,
placeholder,
name,
readOnly,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On avait besoin d'un mode readOnly dans le CRM vu qu'on switch le DropdownList avec le Combobox, donc je l'ai ajouté par la bande.


export const Combobox: FC<ComboboxProps> = ({
allowCustomValue = false,
autoSelectMatchingOption = true,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

En mode multiselect, c'est pas tous les cas d'utilisation qui requiert qu'on sélectionne automatiquement la première option qui match ce que le user écrit.

Dans le cas des document tags dans le CRM, par exemple, les utilisateurs pourraient avoir des tags du genre:

Québec
Québec - Capitale Nationale
Québec - Montérégie
Québec - Estrie
etc.

et on veut éviter que la composante sélectionne "Québec" alors que le user aurait plutôt voulu "Québec - Montérégie" par exemple.

J'ai donc ajouté une prop pour gérer cette fonctionnalité là, mais je la supporte quand même en multiselect des fois que ça serait utile à quelqu'un.

inlineAutoComplete = false,
isLoading = false,
label,
multiselect,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Le birthday boy.

isOptionEnabled,
isOptionSelected, optionsAreEqual,
removeOption,
} from '../listbox/utils';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

J'ai mis certaines fonctions qui semblaient apparaître en double chez le voisin (DropdownList) dans une classe utilitaire pour enlever un peu de gras.


function getBackgroundColor({ disabled, $readOnly, theme }: TextboxProps | TagInputContainerProps): string {
if ($readOnly) {
return theme.component['combobox-readonly-background-color'];
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

J'ai ajouté des tokens de couleur pour le readOnly (mêmes valeurs que pour le DropdownList).

setInputValue('');
clearSelectedOptions();

if (isValueType(value)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Support des valeurs custom au render initial ici.

closeListbox();
}
} else if (multiselect && allowCustomValue && inputValue.trim() !== '') {
const customOption = createCustomOption(inputValue, inputValue) as ComboboxOption;
Copy link
Contributor Author

@ogermain-kronos ogermain-kronos Nov 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Support des valeurs custom via l'écriture dans l'input ici.

@meriouma
Copy link
Contributor

J'ai rebased pour régler le conflit. J'avais fait une modif aux utils que t'as déplacé.

}
}
break;
case 'Enter':
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

La doc dit pour le multiselect que ça devrait être une virgule, mais en y pensant je pense que le Enter est mieux. C'est pas exclu qu'on ait une valeur avec une virgule dedans.
Est-ce que c'est toi @LarryMatte qui avait documenté ça? T'en penses quoi?

@meriouma meriouma force-pushed the dev/DS-1386-combobox-ms branch from d535066 to 42996cb Compare December 23, 2025 21:10
@meriouma meriouma merged commit 8183c7f into master Dec 23, 2025
22 of 23 checks passed
@meriouma meriouma deleted the dev/DS-1386-combobox-ms branch December 23, 2025 21:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants