Skip to content

Commit

Permalink
Merge pull request #353 from panichevoleg/fix/585977-persist-validation
Browse files Browse the repository at this point in the history
Persist validation state in Form controls when Form gets re-rendered
  • Loading branch information
klaidigorishti authored Oct 19, 2021
2 parents 8a9fa8a + edd07db commit df34a43
Show file tree
Hide file tree
Showing 13 changed files with 38 additions and 12 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Precise UI Changelog

## 2.1.3

- Persist validation state in Form controls when Form gets re-rendered

## 2.1.2

- Fix Flyout container styles, add an example
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "precise-ui",
"version": "2.1.2",
"version": "2.1.3",
"description": "Precise UI React component library powered by Styled Components.",
"keywords": [
"react",
Expand Down
4 changes: 3 additions & 1 deletion src/components/Autocomplete/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,9 @@ class AutocompleteInt<T> extends React.Component<SupportedAutocompleteProps<T> &
if (this.state.controlled) {
this.setState({ value });
}
this.setState({ error });
if ('error' in this.props) {
this.setState({ error });
}
}

componentDidMount() {
Expand Down
4 changes: 3 additions & 1 deletion src/components/Checkbox/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ export class CheckboxInt extends React.PureComponent<CheckboxProps, CheckboxStat
if (this.state.controlled) {
this.setState({ value });
}
this.setState({ error });
if ('error' in this.props) {
this.setState({ error });
}
}

componentDidMount() {
Expand Down
4 changes: 3 additions & 1 deletion src/components/ColorPicker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,9 @@ class ColorPickerInt extends React.PureComponent<ColorPickerProps & FormContextP
base,
});
}
this.setState({ error });
if ('error' in this.props) {
this.setState({ error });
}
}

componentDidMount() {
Expand Down
4 changes: 3 additions & 1 deletion src/components/DateField/DateFieldInt.part.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,9 @@ class DateFieldInt extends React.Component<DateFieldProps, DateFieldState> {
this.setState({ value, date: this.parseDate(value) });
}

this.setState({ error });
if ('error' in this.props) {
this.setState({ error });
}
}

componentDidMount() {
Expand Down
4 changes: 3 additions & 1 deletion src/components/DropdownField/DropdownFieldInt.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,9 @@ export class DropdownFieldInt extends React.Component<DropdownFieldProps & FormC
});
}

this.setState({ error });
if ('error' in this.props) {
this.setState({ error });
}
}

private show = () =>
Expand Down
4 changes: 3 additions & 1 deletion src/components/FileSelect/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ class FileSelectInt extends React.Component<FileSelectProps & FormContextProps,
previews: [],
});
}
this.setState({ error });
if ('error' in this.props) {
this.setState({ error });
}
}

private addFileEntries = (ev: React.ChangeEvent<HTMLInputElement>) => {
Expand Down
4 changes: 3 additions & 1 deletion src/components/RadioButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,9 @@ export class RadioButtonInt extends React.PureComponent<RadioButtonIntProps & Fo
if (this.state.controlled) {
this.setState({ value });
}
this.setState({ error });
if ('error' in this.props) {
this.setState({ error });
}
}

componentDidMount() {
Expand Down
4 changes: 3 additions & 1 deletion src/components/RadioButtonGroup/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ class RadioButtonGroupInt extends React.PureComponent<RadioButtonGroupProps & Fo
value,
});
}
this.setState({ error });
if ('error' in this.props) {
this.setState({ error });
}
}

private getNextValue = (groupItemName?: string) => {
Expand Down
4 changes: 3 additions & 1 deletion src/components/TagBuilder/TagBuilderInt.part.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,9 @@ export class TagBuilderInt extends React.Component<TagBuilderProps & FormContext
inputValue: inputValue,
});
}
this.setState({ error });
if ('error' in this.props) {
this.setState({ error });
}
}

componentDidMount() {
Expand Down
4 changes: 3 additions & 1 deletion src/components/TextField/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,9 @@ class TextFieldInt extends React.Component<TextFieldProps & FormContextProps, Te
if (this.state.controlled) {
this.setState({ value });
}
this.setState({ error });
if ('error' in this.props) {
this.setState({ error });
}
}

componentDidMount() {
Expand Down
4 changes: 3 additions & 1 deletion src/components/Toggle/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,9 @@ class ToggleInt extends React.PureComponent<ToggleProps & FormContextProps, Togg
if (this.state.controlled) {
this.setState({ value });
}
this.setState({ error });
if ('error' in this.props) {
this.setState({ error });
}
}

private changeValue() {
Expand Down

0 comments on commit df34a43

Please sign in to comment.