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 have a case in which the submit button of a form should stay disabled until the form is valid. In order to do this I listen for changes in input and constantly check if the form is valid with the form.checkValidity method. When using checkValidity all underlying inputs get validated. This triggers the invalid event on line 446 in bootstrap-select.js which in turn focuses the bootstrap-select button on line 449 (in the dist version).
this.$element.on('invalid', function () {
that.$button
.addClass('bs-invalid')
.focus();
[...]
});
So when I'm inserting some input in a random field and the script checks if the form is valid already, the bootstrap-select component steals focus away from the field I was working in.
Here is an example showing the expected behavior of a select element being focused when responding to validation. See the difference between checkValidity and reportValidity/submit. https://codepen.io/Wimski/pen/jwJwNR
It's too bad the focusing of the element lags a bit behind the invalid event, but a simple timeout can tell you a lot. So my suggestion would be to only focus the bootstrap-select button when the select element gets focused immediately after being invalidated.
I have a case in which the submit button of a form should stay disabled until the form is valid. In order to do this I listen for changes in input and constantly check if the form is valid with the
form.checkValidity
method. When usingcheckValidity
all underlying inputs get validated. This triggers the invalid event on line 446 in bootstrap-select.js which in turn focuses the bootstrap-select button on line 449 (in the dist version).So when I'm inserting some input in a random field and the script checks if the form is valid already, the bootstrap-select component steals focus away from the field I was working in.
See my example:
https://codepen.io/Wimski/pen/weRPVo
Start typing in the first field.
All the code I use:
The text was updated successfully, but these errors were encountered: