File tree Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -120,8 +120,9 @@ <h1>Angular Material Demos</h1>
120120 }
121121 </ button >
122122 < button
123+ #densityTooltip ="matTooltip "
123124 mat-icon-button
124- (click) ="toggleDensity() "
125+ (click) ="toggleDensity(undefined, densityTooltip ) "
125126 [matTooltip] ="'Density: ' + state.density ">
126127 < mat-icon > grid_on</ mat-icon >
127128 </ button >
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ import {MatButtonModule} from '@angular/material/button';
1515import { RouterModule } from '@angular/router' ;
1616import { MatIconModule , MatIconRegistry } from '@angular/material/icon' ;
1717import { MatToolbarModule } from '@angular/material/toolbar' ;
18- import { MatTooltipModule } from '@angular/material/tooltip' ;
18+ import { MatTooltip , MatTooltipModule } from '@angular/material/tooltip' ;
1919import { DevAppDirectionality } from './dev-app-directionality' ;
2020import { DevAppRippleOptions } from './ripple-options' ;
2121import { getAppState , setAppState } from './dev-app-state' ;
@@ -143,13 +143,19 @@ export class DevAppLayout {
143143 location . reload ( ) ;
144144 }
145145
146- toggleDensity ( index ?: number ) {
146+ toggleDensity ( index ?: number , tooltipInstance ?: MatTooltip ) {
147147 if ( index == null ) {
148148 index = ( this . _densityScales . indexOf ( this . state . density ) + 1 ) % this . _densityScales . length ;
149149 }
150150
151151 this . state . density = this . _densityScales [ index ] ;
152152 setAppState ( this . state ) ;
153+
154+ // Keep the tooltip open so we can see what the density was changed to. Ideally we'd
155+ // always show the density in a badge, but the M2 badge is too large for the toolbar.
156+ if ( tooltipInstance ) {
157+ requestAnimationFrame ( ( ) => tooltipInstance . show ( 0 ) ) ;
158+ }
153159 }
154160
155161 toggleRippleDisabled ( value = ! this . state . rippleDisabled ) {
You can’t perform that action at this time.
0 commit comments