adobe / adobe/react-spectrum

Native validation doesn't dismiss errors as the user corrects them

Open
#6,983 12 comments 1 reaction 0 assignees View on GitHub
Dominant language
TypeScript
Stars
15.9k
Forks
1.6k
Avg merge
3d 9m
Merged PRs (30d)
59

Description

### Provide a general summary of the issue here

React ARIA's "native" validation doesn't work like HTML5 native validation works in most browsers, which results in a significantly worse user experience.

### 🤔 Expected Behavior?

In most modern browsers, when an HTML5 validation error is already showing, the validation error will update in real time until the user has fixed it, and then the error will immediately go away without the user blurring the field.

### 😯 Current Behavior

When `validationBehavior` is set to `"native"` and a validation error is showing, the error will never go away until the user blurs the field. The error message also won't update if the native validation issue changes until the user blurs the field.

### 💁 Possible Solution

I think the `useFormValidation` component should have two modes:

- A "lazy" mode which is initially active - in this mode it would only call `state.commitValidation()` in the `change` event handler
- An "eager" mode which becomes active while a native validation error is showing - in this mode if would call `state.commitValidation()` in an `input` event handler

### 🔦 Context

_No response_

### 🖥️ Steps to Reproduce

https://codesandbox.io/s/quirky-meitner-jl79fh?file=/src/App.js

### Version

latest

### What browsers are you seeing the problem on?

Firefox, Chrome, Safari

### If other, please specify.

_No response_

### What operating system are you using?

macOS Sonoma 14.3

### 🧢 Your Company/Team

_No response_

### 🕷 Tracking Issue

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.