mirror of
https://github.com/vector-im/element-web.git
synced 2024-11-16 05:04:57 +08:00
Fix Field validation tooltip sticking if blurred before async validation resolved
This commit is contained in:
parent
0140338ac5
commit
213bc4c3ac
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user