-
-
Notifications
You must be signed in to change notification settings - Fork 173
fix: make controls respond to the invalid
event
#420
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
Conversation
✅ Deploy Preview for oruga-documentation-preview ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
Yes we can avoid it |
@blm768 the PR looks ok but probably it's better release it in the next breaking version (0.6.0), what do you think? |
Waiting until 0.6.0 should be OK; I've got a workaround that I can use for this in the meantime. That'd also give us more time to evaluate suppressing the browser's native pop-up messages. We'll probably only want to do that for controls with a parent field, and it might be worthwhile to make it configurable, although the existing |
36b3e16
to
d464b75
Compare
d464b75
to
64e4e02
Compare
Codecov ReportBase: 63.43% // Head: 62.80% // Decreases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## develop #420 +/- ##
===========================================
- Coverage 63.43% 62.80% -0.64%
===========================================
Files 79 79
Lines 5467 5527 +60
Branches 1513 1535 +22
===========================================
+ Hits 3468 3471 +3
- Misses 1897 1946 +49
- Partials 102 110 +8
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
The first commit in this branch is basically in a reviewable state, although I should probably add some tests. The second commit, which tries to get rid of the browser's native validation tooltip/pop-up, has an issue that will need some further discussion. The basic problem, as it turns out, is that there's not a "good" (well-supported, standards-based, and with minimal code) way to scroll an element into view only if it's not already in the view. All of the "simple" options have problems:
So far, the optimal solution (from a usability perspective) seems to be to use a third-party polyfill for a feature that may be standardized eventually. That doesn't seem like a great option in terms of keeping Oruga's dependencies and bundle size minimal. At this point, it seems like we've got a handful of fairly reasonable options to choose from (possibly including a combination of options):
Does one of those options sound clearly better than the others? |
Looks like this issue will make automated tests tricky. |
64e4e02
to
8c9f79d
Compare
@blm768 the work in this branch is going to finish, we're ready to review all the breaking changes :) About your PR, lgtm and I also agree with you that Oruga should not come with extra dependencies (polyfills included). I don't know which is the best option, seems ok for me to use @jtommy any thoughts? |
Yep; that's what I had in mind. We'd probably use the standard behavior if the user doesn't provide a handler function and skip our built-in behavior entirely if the user does provide one. |
I agree with you! |
dd8a12f
to
217d74c
Compare
Rather than emitting `invalid` events on blur, we should be listening for them.
93cdee2
to
ee4c1ef
Compare
Rather than emitting
invalid
events on blur, we should be listening for them.Fixes #407
Proposed Changes
FormElementMixin.checkHtml5Validity
checks thevalidity
property rather than callingcheckValidity
, so it doesn't emitinvalid
events on blur.FormElementMixin
respond toinvalid
events, which the browser fires when their containing form is submitted.Open Questions
When the form is submitted, most browsers will focus the first invalid field and display a pop-up with a validation message. This is standard behavior for plain HTML inputs, but for Oruga controls inside a field, the pop-up is redundant because we provide our own user-visible error message. Should we suppress the browser's native pop-up by default?