From f16affc69f3c10bae0de6be8f5dcc817ec521b98 Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Thu, 27 Apr 2017 20:31:58 +0200 Subject: [PATCH] fix(select): unable to hide via visibility (#4264) Fixes not being able to hide a `md-select` instance through `visibility: hidden`. Fixes #4247. --- src/lib/select/select.html | 2 +- src/lib/select/select.spec.ts | 4 ++-- src/lib/select/select.ts | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/lib/select/select.html b/src/lib/select/select.html index c1923935b0cf..510da0dc78a4 100644 --- a/src/lib/select/select.html +++ b/src/lib/select/select.html @@ -3,7 +3,7 @@ class="mat-select-placeholder" [class.mat-floating-placeholder]="_selectionModel.hasValue()" [@transformPlaceholder]="_getPlaceholderAnimationState()" - [style.visibility]="_getPlaceholderVisibility()" + [style.opacity]="_getPlaceholderOpacity()" [style.width.px]="_selectedValueWidth"> {{ placeholder }} {{ triggerValue }} diff --git a/src/lib/select/select.spec.ts b/src/lib/select/select.spec.ts index 974176117de8..8ae27762aac9 100644 --- a/src/lib/select/select.spec.ts +++ b/src/lib/select/select.spec.ts @@ -1646,13 +1646,13 @@ describe('MdSelect', () => { fixture.componentInstance.floatPlaceholder = 'never'; fixture.detectChanges(); - expect(placeholder.style.visibility).toBe('visible'); + expect(placeholder.style.opacity).toBe('1'); expect(fixture.componentInstance.select._getPlaceholderAnimationState()).toBeFalsy(); fixture.componentInstance.control.setValue('pizza-1'); fixture.detectChanges(); - expect(placeholder.style.visibility).toBe('hidden'); + expect(placeholder.style.opacity).toBe('0'); expect(fixture.componentInstance.select._getPlaceholderAnimationState()).toBeFalsy(); }); diff --git a/src/lib/select/select.ts b/src/lib/select/select.ts index 57ff65ecddda..54bd2692e892 100644 --- a/src/lib/select/select.ts +++ b/src/lib/select/select.ts @@ -812,11 +812,11 @@ export class MdSelect implements AfterContentInit, OnDestroy, OnInit, ControlVal } /** - * Determines the CSS `visibility` of the placeholder element. + * Determines the CSS `opacity` of the placeholder element. */ - _getPlaceholderVisibility(): 'visible'|'hidden' { + _getPlaceholderOpacity(): string { return (this.floatPlaceholder !== 'never' || this._selectionModel.isEmpty()) ? - 'visible' : 'hidden'; + '1' : '0'; } /** Returns the aria-label of the select component. */