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>
120
120
}
121
121
</ button >
122
122
< button
123
+ #densityTooltip ="matTooltip "
123
124
mat-icon-button
124
- (click) ="toggleDensity() "
125
+ (click) ="toggleDensity(undefined, densityTooltip ) "
125
126
[matTooltip] ="'Density: ' + state.density ">
126
127
< mat-icon > grid_on</ mat-icon >
127
128
</ button >
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ import {MatButtonModule} from '@angular/material/button';
15
15
import { RouterModule } from '@angular/router' ;
16
16
import { MatIconModule , MatIconRegistry } from '@angular/material/icon' ;
17
17
import { MatToolbarModule } from '@angular/material/toolbar' ;
18
- import { MatTooltipModule } from '@angular/material/tooltip' ;
18
+ import { MatTooltip , MatTooltipModule } from '@angular/material/tooltip' ;
19
19
import { DevAppDirectionality } from './dev-app-directionality' ;
20
20
import { DevAppRippleOptions } from './ripple-options' ;
21
21
import { getAppState , setAppState } from './dev-app-state' ;
@@ -143,13 +143,19 @@ export class DevAppLayout {
143
143
location . reload ( ) ;
144
144
}
145
145
146
- toggleDensity ( index ?: number ) {
146
+ toggleDensity ( index ?: number , tooltipInstance ?: MatTooltip ) {
147
147
if ( index == null ) {
148
148
index = ( this . _densityScales . indexOf ( this . state . density ) + 1 ) % this . _densityScales . length ;
149
149
}
150
150
151
151
this . state . density = this . _densityScales [ index ] ;
152
152
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
+ }
153
159
}
154
160
155
161
toggleRippleDisabled ( value = ! this . state . rippleDisabled ) {
You can’t perform that action at this time.
0 commit comments