From 8d9bbbf008de83f4988d25aedaf1e153e41ad60f Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Thu, 8 Jun 2017 23:32:35 +0200 Subject: [PATCH] fix(checkbox): margin for empty checkboxes incorrectly added (#4730) * 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 --- src/lib/checkbox/checkbox.html | 4 +- src/lib/checkbox/checkbox.spec.ts | 62 +++++++++++++++++++++++++------ src/lib/checkbox/checkbox.ts | 16 ++++---- src/lib/checkbox/index.ts | 4 +- 4 files changed, 63 insertions(+), 23 deletions(-) diff --git a/src/lib/checkbox/checkbox.html b/src/lib/checkbox/checkbox.html index e07b211a679..78090d6208b 100644 --- a/src/lib/checkbox/checkbox.html +++ b/src/lib/checkbox/checkbox.html @@ -1,6 +1,6 @@