Skip to content

Commit df34a43

Browse files
Merge pull request #353 from panichevoleg/fix/585977-persist-validation
Persist validation state in Form controls when Form gets re-rendered
2 parents 8a9fa8a + edd07db commit df34a43

File tree

13 files changed

+38
-12
lines changed

13 files changed

+38
-12
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Precise UI Changelog
22

3+
## 2.1.3
4+
5+
- Persist validation state in Form controls when Form gets re-rendered
6+
37
## 2.1.2
48

59
- Fix Flyout container styles, add an example

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "precise-ui",
3-
"version": "2.1.2",
3+
"version": "2.1.3",
44
"description": "Precise UI React component library powered by Styled Components.",
55
"keywords": [
66
"react",

src/components/Autocomplete/index.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,9 @@ class AutocompleteInt<T> extends React.Component<SupportedAutocompleteProps<T> &
151151
if (this.state.controlled) {
152152
this.setState({ value });
153153
}
154-
this.setState({ error });
154+
if ('error' in this.props) {
155+
this.setState({ error });
156+
}
155157
}
156158

157159
componentDidMount() {

src/components/Checkbox/index.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ export class CheckboxInt extends React.PureComponent<CheckboxProps, CheckboxStat
100100
if (this.state.controlled) {
101101
this.setState({ value });
102102
}
103-
this.setState({ error });
103+
if ('error' in this.props) {
104+
this.setState({ error });
105+
}
104106
}
105107

106108
componentDidMount() {

src/components/ColorPicker/index.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,9 @@ class ColorPickerInt extends React.PureComponent<ColorPickerProps & FormContextP
228228
base,
229229
});
230230
}
231-
this.setState({ error });
231+
if ('error' in this.props) {
232+
this.setState({ error });
233+
}
232234
}
233235

234236
componentDidMount() {

src/components/DateField/DateFieldInt.part.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,9 @@ class DateFieldInt extends React.Component<DateFieldProps, DateFieldState> {
203203
this.setState({ value, date: this.parseDate(value) });
204204
}
205205

206-
this.setState({ error });
206+
if ('error' in this.props) {
207+
this.setState({ error });
208+
}
207209
}
208210

209211
componentDidMount() {

src/components/DropdownField/DropdownFieldInt.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,9 @@ export class DropdownFieldInt extends React.Component<DropdownFieldProps & FormC
245245
});
246246
}
247247

248-
this.setState({ error });
248+
if ('error' in this.props) {
249+
this.setState({ error });
250+
}
249251
}
250252

251253
private show = () =>

src/components/FileSelect/index.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,9 @@ class FileSelectInt extends React.Component<FileSelectProps & FormContextProps,
9393
previews: [],
9494
});
9595
}
96-
this.setState({ error });
96+
if ('error' in this.props) {
97+
this.setState({ error });
98+
}
9799
}
98100

99101
private addFileEntries = (ev: React.ChangeEvent<HTMLInputElement>) => {

src/components/RadioButton/index.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,9 @@ export class RadioButtonInt extends React.PureComponent<RadioButtonIntProps & Fo
156156
if (this.state.controlled) {
157157
this.setState({ value });
158158
}
159-
this.setState({ error });
159+
if ('error' in this.props) {
160+
this.setState({ error });
161+
}
160162
}
161163

162164
componentDidMount() {

src/components/RadioButtonGroup/index.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ class RadioButtonGroupInt extends React.PureComponent<RadioButtonGroupProps & Fo
8383
value,
8484
});
8585
}
86-
this.setState({ error });
86+
if ('error' in this.props) {
87+
this.setState({ error });
88+
}
8789
}
8890

8991
private getNextValue = (groupItemName?: string) => {

src/components/TagBuilder/TagBuilderInt.part.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,9 @@ export class TagBuilderInt extends React.Component<TagBuilderProps & FormContext
142142
inputValue: inputValue,
143143
});
144144
}
145-
this.setState({ error });
145+
if ('error' in this.props) {
146+
this.setState({ error });
147+
}
146148
}
147149

148150
componentDidMount() {

src/components/TextField/index.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,9 @@ class TextFieldInt extends React.Component<TextFieldProps & FormContextProps, Te
140140
if (this.state.controlled) {
141141
this.setState({ value });
142142
}
143-
this.setState({ error });
143+
if ('error' in this.props) {
144+
this.setState({ error });
145+
}
144146
}
145147

146148
componentDidMount() {

src/components/Toggle/index.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,9 @@ class ToggleInt extends React.PureComponent<ToggleProps & FormContextProps, Togg
121121
if (this.state.controlled) {
122122
this.setState({ value });
123123
}
124-
this.setState({ error });
124+
if ('error' in this.props) {
125+
this.setState({ error });
126+
}
125127
}
126128

127129
private changeValue() {

0 commit comments

Comments
 (0)