-
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
Md-Checkbox has no margin when using dynamic label after #2121 #4720
Comments
With angular#2121 the margin will be removed for checkboxes that don't have any label set. A problem is that the Checkbox uses the OnPush change detection strategy and therefore the checkbox is not able to detect any delayed / async label change. This means that checkboxes that set their label from an async binding will not have any margin until the users clicks on the checkbox. Using the `cdkObserveContent` seems to be an elegant approach when using the OnPush strategy. The `:empty` CSS selector would be more elegant but it's very sensitive about whitespaces and therefore it doesn't work properly. Fixes angular#4720
With angular#2121 the margin will be removed for checkboxes that don't have any label set. A problem is that the Checkbox uses the OnPush change detection strategy and therefore the checkbox is not able to detect any delayed / async label change. This means that checkboxes that set their label from an async binding will not have any margin until the users clicks on the checkbox. Using the `cdkObserveContent` seems to be an elegant approach when using the OnPush strategy. The `:empty` CSS selector would be more elegant but it's very sensitive about whitespaces and therefore it doesn't work properly. Fixes angular#4720
With angular#2121 the margin will be removed for checkboxes that don't have any label set. A problem is that the Checkbox uses the OnPush change detection strategy and therefore the checkbox is not able to detect any delayed / async label change. This means that checkboxes that set their label from an async binding will not have any margin until the users clicks on the checkbox. Using the `cdkObserveContent` seems to be an elegant approach when using the OnPush strategy. The `:empty` CSS selector would be more elegant but it's very sensitive about whitespaces and therefore it doesn't work properly. Fixes angular#4720
* fix(checkbox): margin for empty checkboxes incorrectly added With #2121 the margin will be removed for checkboxes that don't have any label set. A problem is that the Checkbox uses the OnPush change detection strategy and therefore the checkbox is not able to detect any delayed / async label change. This means that checkboxes that set their label from an async binding will not have any margin until the users clicks on the checkbox. Using the `cdkObserveContent` seems to be an elegant approach when using the OnPush strategy. The `:empty` CSS selector would be more elegant but it's very sensitive about whitespaces and therefore it doesn't work properly. Fixes #4720 * Updates
Same issue here too. |
@andrewseguin I don't think the issue is completely fixed. Somehow the markForChecked is not called and thus the class is first removed after interacting with the UI in some other way. |
Same issue here, any proposed workarounds? |
@andrewseguin @devversion Could you please re-open the issue as the problem still exists? |
@andreasrueedlinger Thanks for the ping. I will have a look later this day and re-open if I can reproduce it. |
Sorry forgot to append my sample:
Seems that the issue is the translate pipe. |
@devversion I created a new working stackblitz here: https://angular-material2-issue-z8w4ml.stackblitz.io |
Usually if the label of the checkbox or slide-toggle is empty, we remove the margin between label container and thumb/check because otherwise there would be too much spacing. Currently if developers use a component inside of the checkbox or slide-toggle in order to render the label, the margin is accidentally removed and the label looks misplaced. This is because the `cdkObserveContent` event runs outside of the `NgZone` and no change detection round _checks_ the checkbox or slide-toggle. Fixes angular#4720
Usually if the label of the checkbox or slide-toggle is empty, we remove the margin between label container and thumb/check because otherwise there would be too much spacing. Currently if developers use a component inside of the checkbox or slide-toggle in order to render the label, the margin is accidentally removed and the label looks misplaced. This is because the `cdkObserveContent` event runs outside of the `NgZone` and no change detection round _checks_ the checkbox or slide-toggle. Fixes #4720
* fix(checkbox, slide-toggle): no margin if content is projected Usually if the label of the checkbox or slide-toggle is empty, we remove the margin between label container and thumb/check because otherwise there would be too much spacing. Currently if developers use a component inside of the checkbox or slide-toggle in order to render the label, the margin is accidentally removed and the label looks misplaced. This is because the `cdkObserveContent` event runs outside of the `NgZone` and no change detection round _checks_ the checkbox or slide-toggle. Fixes #4720 * Add tests
This seems to be still an issue in @angular/material 7.3.6. |
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. |
Bug, feature request, or proposal:
After upgrading to material 2.0.0-beta5, checkboxes on my login screen no longer have margin on their right.
Apparently due to this change:
#2121
and to the fact I use dynamic labels (translated by ngx-translate to be precise).
I use something like that:
<md-checkbox [(ngModel)]="savePassword">{{ "tx_Login_SavePassword" | translate }}
What is the expected behavior?
To have margin (space between the checkbox and its label) on the right of the checkbox (no mat-checkbox-inner-container-no-side-margin class)
What is the current behavior?
The class mat-checkbox-inner-container-no-side-margin is added to the checkbox when rendering the form. it only disappears when one clicks on the checkbox.
What are the steps to reproduce?
Here is the Plunker reproducing the problem (without ngx-translate but using a simple settimeout instead):
https://plnkr.co/5CFp9x
What is the use-case or motivation for changing an existing behavior?
Working as it was in previous 2.0.0-beta
Which versions of Angular, Material, OS, TypeScript, browsers are affected?
Material 2.0.0-beta5
Is there anything else we should know?
Don't think so but please ask if I forgot something
The text was updated successfully, but these errors were encountered: