You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm currently working my way through the react-stately library and have a question regarding the implementation of the useFormValidationState() hook.
Why is the equal check of resetValidation() ran against lastError instead of the current validity? The comment above the line seems to imply a desire to display immediate change, which this won't do?
// Update the currently displayed validation state to valid on form reset,
// even if the native validity says it isn't. It'll show again on the next form submit.
leterror=DEFAULT_VALIDATION_RESULT;
if(!isEqualValidation(error,lastError.current)){
lastError.current=error;
setCurrentValidity(error);
}
Wouldn't it make more sense to look something like this:
// Update the currently displayed validation state to valid on form reset,// even if the native validity says it isn't. It'll show again on the next form submit.leterror=DEFAULT_VALIDATION_RESULT;if(!isEqualValidation(error,currentValidity)){lastError.current=currentValidity;setCurrentValidity(error);}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hey 👋 ,
I'm currently working my way through the react-stately library and have a question regarding the implementation of the
useFormValidationState()
hook.Why is the equal check of
resetValidation()
ran against lastError instead of the current validity? The comment above the line seems to imply a desire to display immediate change, which this won't do?react-spectrum/packages/@react-stately/form/src/useFormValidationState.ts
Lines 161 to 167 in a3d77ab
Wouldn't it make more sense to look something like this:
Beta Was this translation helpful? Give feedback.
All reactions