-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Description
Description
Inconsistent behaviour between chip unselection vs. unselecting the chip by setting null value as formControl
When I want to programatically unselect a chip within a formGroup I can not setValue(undefined) only setValue(null).
I find that the behaviour is inconsistent and I understand why the initial value is undefined in case nothing was put onto the component. But after unselection I think it would be more rational to have it set up as null. Or preferably having null always as a default value within formGroup.
- I find this behaviour inconsistent and in case that I need to programatically unselect chipbox, then I need to map the final undefined value to null to have it correctly set in my project

Reproduction
StackBlitz link:
Steps to reproduce:
- Select one of the three chips, for example 'Large'
- Click on the button set as null
- This works as expected, and the chips has value null.
- Try to click on Large again
- Unselect the selection by clicking on 'Large' again
You receive undefined


Expected Behavior
Expected behaviour is to have either always undefined or null, or be able to set undefined programatically.
But preferably null over undefined
Actual Behavior
Inconsistent behaviour between myControl.setValue(null)
- which is unselecting chip from the component
And the actual clicking on the selected chip which it makes unselected but automatically set value as undefined
Environment
- Angular:
- CDK/Material:
- Browser(s):
- Operating System (e.g. Windows, macOS, Ubuntu):