🐛(react) fix multi select menu opening

At first we had a simple bug were it was not possible to open the
menu by clicking on the label. This fix is a rework to consider
the select wrapper as the toggle button itself, which is what we
do on the mono version. This change caused various tests to fail.
This commit is contained in:
Nathan Vasse
2024-01-31 17:55:41 +01:00
committed by NathanVss
parent 1445f4a222
commit d61ab65d82
6 changed files with 16 additions and 13 deletions

View File

@@ -63,6 +63,10 @@ export interface SelectMultiAuxProps extends SubProps {
export const SelectMultiAux = ({ children, ...props }: SelectMultiAuxProps) => {
const { t } = useCunningham();
const labelProps = props.downshiftReturn.getLabelProps();
// We need to remove onBlur from toggleButtonProps because it triggers a menu closing each time
// we tick a checkbox using the monoline style.
const { onBlur, ...toggleProps } = props.downshiftReturn.toggleButtonProps;
return (
<Field {...props}>
<div
@@ -85,6 +89,7 @@ export const SelectMultiAux = ({ children, ...props }: SelectMultiAuxProps) => {
props.downshiftReturn.isOpen && !props.disabled,
})}
{...props.downshiftReturn.wrapperProps}
{...toggleProps}
>
{props.selectedItems.map((selectedItem, index) => (
<input
@@ -138,7 +143,6 @@ export const SelectMultiAux = ({ children, ...props }: SelectMultiAuxProps) => {
</span>
}
disabled={props.disabled}
{...props.downshiftReturn.toggleButtonProps}
/>
</div>
<div className="c__select__inner__value">