Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: change input type in error_boundary example #2171

Closed
wants to merge 1 commit into from

Conversation

webmstk
Copy link
Contributor

@webmstk webmstk commented Jan 7, 2024

Chrome (mac) doesn't allow type non-digits in numeric inputs, so I removed type=number from input to make example more correct in this case.

@gbj
Copy link
Collaborator

gbj commented Jan 7, 2024

First: I very much appreciate the spirit of the PR, which I think is that the example is unrealistic, and it is much better to enforce constraints like this by doing them in built-in HTML rather than in user-land code, for many reasons. I 100% agree with that.

But I also notice that while you refer to Chrome, this constraint is not the same in other browsers. Firefox and Safari, at least in the versions I have installed, both display type="number" chrome (up and down arrows to change number, etc.) but don't enforce the validation; if I type or paste foo into them, foo appears in the input and the failed parsing triggers the <ErrorBoundary/>

In fact in Chrome, on an invalid copy and paste the input event still fires and tries to set the signal to a number, and fails to parse it, leaving a blank space in the UI and a blank value. In this case triggering the <ErrorBoundary/> is actually the only indication of an invalid input other than the browser just doing nothing!

So ironically assuming that the browser will enforce these pretty obvious constraints has the potential to make your UX worse because the behavior is incosistent across browsers.

I'd be open to either

  1. adding an explanatory comment along those lines, saying that this is ensuring a consistent validation experience across browsers
  2. creating a more realistic example if you can think of one: i.e., rather than loosening the browser constraint, creating a more realistic situation where we might have an error on the Rust side

@webmstk
Copy link
Contributor Author

webmstk commented Jan 9, 2024

Ok, let's stick with an exisiting example, I don't think it is a big deal.
I'll make a new pr if I come up with more realistic example :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants