-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
Reactive Forms - Mat Select - doesn't trigger form or control as invalid after control has been touched, and validator.required is set to true #29092
Comments
Hi, can you please provide a working stackblitz repro, thank you. |
Pls see here: https://stackblitz.com/edit/stackblitz-starters-gs9gmh?file=src%2Fmain.ts (but, in Stackblitz, I get an allow any property add 'NO_ERRORS_SCHEMA' to the '@Component.schemas' of this component. [plugin angular-compiler] for the angular component) |
The expected behavior here is debatable. From As for |
Fair points. |
Hi, I still couldn't get this to work, in JetBrains. |
Could you please have a look at it from the MatSelect perspective? Feel free to open a form-related issue if there are limitations there. |
I think I'll open another issue. Am I missing something though? Surely the behaviour should be the same as a normal input field - so the behaviour is consistent. Once it's touched, and if it is required, then after it has been touched, it should become invalid. Before it's touched, it's fine for it to be valid. |
Which @angular/* package(s) are the source of the bug?
forms
Is this a regression?
Yes
Description
With this code
Current bug behaviour is that:
If the control gets loaded with data that is not amongst the allowable options, it will display
'Select a job title' - i.e. the placeholder.
If I touch the control and select None, the control (and form) will become invalid, saying the field is required - great!
However, if I touch the control and don't select None, or the other options, and unclick away from the contrl, I'd expect that since I have a validator.required validator on the cnotrl, that because I touched the control, it should ALSO say control (and form) are invalid, when I unclick away from it (just like what happens with a normal input field)
This currently doesn' happen, and means if the data loaded initially is wrong, a user can send back the same invalid data (since Angular never sees the form as invalid)
Please provide a link to a minimal reproduction of the bug
Reproduction on Stackblitz
Please provide the exception or error you saw
Please provide the environment you discovered this bug in (run
ng version
)No response
Anything else?
No response
The text was updated successfully, but these errors were encountered: