From 213bc4c3ac610726331040460c309e6c1ea5035f Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 17 Dec 2019 14:28:18 +0000 Subject: [PATCH 1/2] Fix Field validation tooltip sticking if blurred before async validation resolved --- src/components/views/elements/Field.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/components/views/elements/Field.js b/src/components/views/elements/Field.js index 0a737d963a..bdbf32333e 100644 --- a/src/components/views/elements/Field.js +++ b/src/components/views/elements/Field.js @@ -66,10 +66,14 @@ export default class Field extends React.PureComponent { this.state = { valid: undefined, feedback: undefined, + focused: false, }; } onFocus = (ev) => { + this.setState({ + focused: true, + }); this.validate({ focused: true, }); @@ -88,6 +92,9 @@ export default class Field extends React.PureComponent { }; onBlur = (ev) => { + this.setState({ + focused: false, + }); this.validate({ focused: false, }); @@ -112,7 +119,8 @@ export default class Field extends React.PureComponent { allowEmpty, }); - if (feedback) { + // this method is async and we may have been blurred since validate was called so check + if (this.state.focused && feedback) { this.setState({ valid, feedback, From 0e86c2648d3c248650fdd4cec731331ea0a95039 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 17 Dec 2019 14:36:20 +0000 Subject: [PATCH 2/2] improve comment --- src/components/views/elements/Field.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/views/elements/Field.js b/src/components/views/elements/Field.js index bdbf32333e..cee33205d7 100644 --- a/src/components/views/elements/Field.js +++ b/src/components/views/elements/Field.js @@ -119,7 +119,8 @@ export default class Field extends React.PureComponent { allowEmpty, }); - // this method is async and we may have been blurred since validate was called so check + // this method is async and so we may have been blurred since the method was called + // if we have then hide the feedback as withValidation does if (this.state.focused && feedback) { this.setState({ valid,