Skip to content

Commit

Permalink
Merge pull request #820 from lumapps/chore/select-multiple-forward-props
Browse files Browse the repository at this point in the history
chore(select-multiple): forward props to wrapper
  • Loading branch information
gcornut authored Apr 20, 2022
2 parents 834000f + b47868f commit dc387c4
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- Added forwarded props to the `SelectMultiple` component.

## [2.2.15][] - 2022-04-14

### Fixed
Expand Down
25 changes: 25 additions & 0 deletions packages/lumx-react/src/components/select/SelectMultiple.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ const setup = (props: SetupProps = {}, shallowRendering = true) => {
(n: ShallowWrapper | ReactWrapper) => n.name() === 'InputHelper' && n.prop('kind') === Kind.info,
),
input: wrapper.find('#select-uid:not(SelectMultipleField)').first(),
chip: wrapper.find('Chip'),
inputWrapper: wrapper.find('.lumx-select__wrapper'),
props,
wrapper,
};
Expand Down Expand Up @@ -188,6 +190,29 @@ describe(`<SelectMultiple>`, () => {
expect(error).toExist();
expect(helper).toExist();
});

it('should have a data-id as prop', () => {
const { inputWrapper } = setup(
{
'data-id': 'select',
},
false,
);

expect(inputWrapper.prop('data-id')).toEqual('select');
});

it('should have a data-id as prop with Chip variant', () => {
const { chip } = setup(
{
'data-id': 'select',
variant: SelectVariant.chip,
},
false,
);

expect(chip.prop('data-id')).toEqual('select');
});
});

// 3. Test events.
Expand Down
3 changes: 3 additions & 0 deletions packages/lumx-react/src/components/select/SelectMultiple.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export const SelectMultipleField: React.FC<SelectMultipleProps> = ({
theme,
value,
variant,
...forwardedProps
}) => (
<>
{variant === SelectVariant.input && (
Expand All @@ -99,6 +100,7 @@ export const SelectMultipleField: React.FC<SelectMultipleProps> = ({
onKeyDown={handleKeyboardNav}
tabIndex={isDisabled ? undefined : 0}
aria-disabled={isDisabled || undefined}
{...forwardedProps}
>
<div className={`${CLASSNAME}__chips`}>
{!isEmpty &&
Expand Down Expand Up @@ -139,6 +141,7 @@ export const SelectMultipleField: React.FC<SelectMultipleProps> = ({
onClick={onInputClick}
ref={anchorRef as RefObject<HTMLAnchorElement>}
theme={theme}
{...forwardedProps}
>
{isEmpty && <span>{label}</span>}

Expand Down

0 comments on commit dc387c4

Please sign in to comment.