Skip to content

Commit

Permalink
Merge pull request #677 from lumapps/fix/is-required
Browse files Browse the repository at this point in the history
fix(input-field): fix isRequired props ui and support
  • Loading branch information
gcornut authored Jul 15, 2021
2 parents 355dd1c + e5399a8 commit e210e05
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 0 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- AutoComplete: Added `isRequired` prop to the component to indicated if field is required
- AutoCompleteMultiple: Added `isRequired` prop to the component to indicated if field is required

### Fixed

- TextField: Add space after asterisk if component has `isRequired` props

## [1.0.18][] - 2021-06-28

### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

.#{$lumx-base-prefix}-input-label {
&--is-required:before {
margin-right: $lumx-spacing-unit-tiny;
content: '*';
font-weight: 700;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ describe(`<${Autocomplete.displayName}>`, () => {
))}
</List>
),
label: 'Field label',
isOpen: true,
isRequired: true,
onChange: jest.fn(),
value: '',
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ export interface AutocompleteProps extends GenericProps {
* @see {@link TextFieldProps#isDisabled}
*/
isDisabled?: boolean;
/**
* Whether the component is required or not.
* @see {@link TextFieldProps#isRequired}
*/
isRequired?: boolean;
/**
* Whether the text field is displayed with valid style or not.
* @see {@link TextFieldProps#isValid}
Expand Down Expand Up @@ -200,6 +205,7 @@ export const Autocomplete: Comp<AutocompleteProps, HTMLDivElement> = forwardRef(
inputRef,
clearButtonProps,
isDisabled = disabled,
isRequired,
isOpen,
isValid,
label,
Expand Down Expand Up @@ -241,6 +247,7 @@ export const Autocomplete: Comp<AutocompleteProps, HTMLDivElement> = forwardRef(
inputRef={mergeRefs(inputAnchorRef, inputRef) as any}
clearButtonProps={clearButtonProps}
isDisabled={isDisabled}
isRequired={isRequired}
isValid={isValid}
label={label}
name={name}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ describe(`<${AutocompleteMultiple.displayName}>`, () => {
text: 'Montevideo',
},
],
label: 'Field label',
isOpen: true,
isRequired: true,
onChange: jest.fn(),
value: '',
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export const AutocompleteMultiple: Comp<AutocompleteMultipleProps, HTMLDivElemen
inputRef,
clearButtonProps,
isDisabled,
isRequired,
isOpen,
isValid,
label,
Expand Down Expand Up @@ -130,6 +131,7 @@ export const AutocompleteMultiple: Comp<AutocompleteMultipleProps, HTMLDivElemen
</ChipGroup>
}
isDisabled={isDisabled}
isRequired={isRequired}
clearButtonProps={clearButtonProps}
isValid={isValid}
label={label}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ exports[`<Autocomplete> Snapshots and structure should render correctly 1`] = `
>
<TextField
inputRef={[Function]}
isRequired={true}
label="Field label"
onChange={[MockFunction]}
textFieldRef={
Object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ exports[`<AutocompleteMultiple> Snapshots and structure should render correctly
closeOnClickAway={true}
closeOnEscape={true}
isOpen={true}
isRequired={true}
label="Field label"
onChange={[MockFunction]}
shouldFocusOnClose={false}
value=""
Expand Down

0 comments on commit e210e05

Please sign in to comment.