Skip to content
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(checkbox): margin for empty checkboxes incorrectly added #4730

Merged
merged 2 commits into from
Jun 8, 2017

Conversation

devversion
Copy link
Member

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

@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label May 22, 2017
@devversion devversion added in progress This issue is currently in progress and removed pr: needs review labels May 22, 2017
@jelbourn
Copy link
Member

It makes me generally unhappy that even something as simple as checkbox has to have a MutationObserver (which is the natural escalation here). Don't know of another way to handle this, though (until :blank is well-supported).

@devversion devversion added pr: needs review and removed in progress This issue is currently in progress labels May 23, 2017
@devversion
Copy link
Member Author

@jelbourn Reworked it a bit more. Yeah I'm not too happy with the solution either.

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
Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, this approach doesn't bother me too much now with the markForCheck

@jelbourn jelbourn added pr: lgtm action: merge The PR is ready for merge by the caretaker and removed pr: needs review labels Jun 6, 2017
@andrewseguin andrewseguin merged commit 8d9bbbf into angular:master Jun 8, 2017
devversion added a commit to devversion/material2 that referenced this pull request Sep 6, 2017
* Removes the side-margin of the actual indicator of the slide-toggle if the user label is empty (similar as in angular#4730)

Fixes angular#6868
devversion added a commit to devversion/material2 that referenced this pull request Sep 7, 2017
* Removes the side-margin of the actual indicator of the slide-toggle if the user label is empty (similar as in angular#4730)

Fixes angular#6868
devversion added a commit to devversion/material2 that referenced this pull request Sep 7, 2017
* Removes the side-margin of the actual indicator of the slide-toggle if the user label is empty (similar as in angular#4730)

Fixes angular#6868
mmalerba pushed a commit that referenced this pull request Sep 12, 2017
…6881)

* Removes the side-margin of the actual indicator of the slide-toggle if the user label is empty (similar as in #4730)

Fixes #6868
josephperrott pushed a commit to josephperrott/components that referenced this pull request Sep 15, 2017
…ngular#6881)

* Removes the side-margin of the actual indicator of the slide-toggle if the user label is empty (similar as in angular#4730)

Fixes angular#6868
@devversion devversion deleted the fix/checkbox-label-watch branch November 11, 2017 10:23
@zukasmichael
Copy link

is there any workaround now for ^5.1.0 ?

@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Md-Checkbox has no margin when using dynamic label after #2121
6 participants