-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
Fix: Input/Radio should be disabled when disabling the formcontrol #1242
Conversation
I tried the checkbox in an demo app and it disables & enables successfully. So it's only something with the change-detection in the testenvironment that's not working as expected. |
formControl.disable(); | ||
fixture.detectChanges(); | ||
|
||
fixture.whenStable().then(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kara, is using whenStable
supposed to be necessary for changing disabled state?
(here and elsewhere)
fixture.detectChanges(); | ||
fixture.whenStable().then(() => { | ||
expect(inputElement.disabled).toBeTruthy('InputElement should be disabled'); | ||
expect(mdInput.disabled).toBeTruthy('Component should be disabled'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh, I had no idea you could pass a message like that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It helps alot when looking for errors :)
fixture = TestBed.createComponent(RadioGroupWithReactiveForms); | ||
fixture.detectChanges(); | ||
|
||
fixture.whenStable().then(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you need a whenStable
in the beforeEach
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't need that one, got removed in the next commit
radioInputs.forEach(input => | ||
expect(input.disabled).toBeTruthy(input.value + ' should be disabled')); | ||
nativeRadioInputs.forEach(input => | ||
expect(input.disabled).toBeTruthy('Native ' + input.id + ' should be disabled')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use template strings for these messages
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@kara should take a look |
@Sabartius can you push the change for checkbox including the failing test? We can take a look at see what needs to be changed. |
@jelbourn Pushed it. Hope you can find the problem :) |
@tinayuangao can you follow up on this? |
Superseded by #1750 |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Fixes #1171 for Input-Elements and Radio
@jelbourn @kara I've tried to repair the checkbox too, but i couldn't test it properly.
My test for the checkbox only worked, when i deleted the ChangeDetectionStrategy.OnPush from the Component, but thats not the solution i wanted to push.