Skip to content

Commit

Permalink
fix(select): unable to hide via visibility (angular#4264)
Browse files Browse the repository at this point in the history
Fixes not being able to hide a `md-select` instance through `visibility: hidden`.

Fixes angular#4247.
  • Loading branch information
crisbeto authored and mmalerba committed Apr 27, 2017
1 parent 6a34f6f commit f16affc
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/lib/select/select.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 }} </span>
<span class="mat-select-value" *ngIf="_selectionModel.hasValue()">
<span class="mat-select-value-text">{{ triggerValue }}</span>
Expand Down
4 changes: 2 additions & 2 deletions src/lib/select/select.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});

Expand Down
6 changes: 3 additions & 3 deletions src/lib/select/select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down

0 comments on commit f16affc

Please sign in to comment.