mat-select with validation not kicked when focus is lost
See original GitHub issueBug, feature request, or proposal:
In my opinion bug with mat-select
. The error message is not visible when dropdown is closed; focus is not behaving properly with “required” attribute applied.
What is the expected behavior?
When focus is not on the control anymore, the error message should be visible.
What is the current behavior?
When focus is lost, the error message is not immediately visible.
What are the steps to reproduce?
- http://plnkr.co/edit/K6hyF9?p=preview
- Click on “favorite options” on the left hand side
- Click out of dropdown to cancel the selection
- Notice the visible “this field is required message”
- Click on “favorite food”
- click out of dropdown to cancel the selection
- notice that “this field is required” is not visible + the bottom line thickness is a little bit bigger than standard
- click again outside of the control, to remove focus on the control
- the “this field is required” message is visible now
What is the use-case or motivation for changing an existing behavior?
As on the plunker shown, autocomplete is behaving move intuitevly when deselecting / closing the dropdown. Validation occurs immediatelly as you would expect it. With mat-select it’s not. In order to kick off the validation, you need to click twice somewhere on the form (some sort).
Which versions of Angular, Material, OS, TypeScript, browsers are affected?
material: 5.0.0-rc.1-6a9fbfe angular: as for version above OS: win 10 64bit enterprise browser: all
Is there anything else we should know?
nope, keep up the good work over this repository 😃
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:5 (2 by maintainers)
Top Results From Across the Web
mat-select required validation not working - Stack Overflow
Since I want the "selection" is a required field, the "submit" button should be disabled when the form is rendered. However, the "submit"...
Read more >Select | Angular Material
<mat-select> is a form control for selecting a value from a set of options, similar to the native <select> element. You can read...
Read more >Working with Angular 4 Forms: Nesting and Input Validation
Validating user inputs is an essential part of any robust web application. Angular 4 makes it especially easy for both template-driven and reactive...
Read more >Angular Form Validation on Blur and Submit - Fiyaz Hasan
That's cool but not the behavior you want when you have several Form Controls in your form model for performance reasons. But you...
Read more >Angular Reactive Forms: trigger validation on submit
For this example, we will consider a field has validation error when the field is not valid and it has been touched (meaning...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@willshowell this is not what I would expect. I would expect the
mat-select
to behave likemat-autocomplete
in this example (plunker above). I am explicitly clicking outside of select’s expanded dropdown to deselect, ergo to loose the focus from the control. I don’t want to do extra click to “actually” quit the control and then to loose focus 😃 😃If we take the situation as you say, it means that in autocomplete there is a bug, because the focus is lost when you deselect the value.
Using keyboard keys as you mentioned is not showing the issue. Using keyboard this is behaving properly as expected. True that.
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.