@@ -9,8 +9,8 @@ import {Subscription} from 'rxjs';
9
9
styleUrls : [ './button-bar.component.scss' ]
10
10
} )
11
11
export class ButtonBarComponent implements OnInit , OnDestroy {
12
- @Input ( ) navItems : NavItem [ ] ;
13
- watcher : Subscription ;
12
+ @Input ( ) navItems : NavItem [ ] | undefined ;
13
+ watcher : Subscription | undefined ;
14
14
namedButtons : NavItem [ ] = [ ] ;
15
15
iconButtons : NavItem [ ] = [ ] ;
16
16
overflowMenuItems : NavItem [ ] = [ ] ;
@@ -30,25 +30,27 @@ export class ButtonBarComponent implements OnInit, OnDestroy {
30
30
}
31
31
32
32
onMediaChange ( ) {
33
- const items = this . navItems . slice ( ) ;
34
- this . namedButtons = [ ] ;
35
- this . iconButtons = [ ] ;
36
- this . overflowMenuItems = [ ] ;
33
+ if ( this . navItems ) {
34
+ const items = this . navItems . slice ( ) ;
35
+ this . namedButtons = [ ] ;
36
+ this . iconButtons = [ ] ;
37
+ this . overflowMenuItems = [ ] ;
37
38
38
- if ( this . mediaService . isActive ( 'xs' ) ) {
39
- this . iconButtons = this . iconButtons . concat ( items . splice ( 0 , 5 ) ) ;
40
- } else if ( this . mediaService . isActive ( 'sm' ) ) {
41
- this . namedButtons = this . namedButtons . concat ( items . splice ( 0 , 6 ) ) ;
42
- } else if ( this . mediaService . isActive ( 'md' ) ) {
43
- this . namedButtons = this . namedButtons . concat ( items . splice ( 0 , 8 ) ) ;
44
- } else if ( this . mediaService . isActive ( 'lg' ) ) {
45
- this . namedButtons = this . namedButtons . concat ( items . splice ( 0 , 12 ) ) ;
46
- } else if ( this . mediaService . isActive ( 'xl' ) ) {
47
- this . namedButtons = this . namedButtons . concat ( items . splice ( 0 , 16 ) ) ;
48
- }
39
+ if ( this . mediaService . isActive ( 'xs' ) ) {
40
+ this . iconButtons = this . iconButtons . concat ( items . splice ( 0 , 5 ) ) ;
41
+ } else if ( this . mediaService . isActive ( 'sm' ) ) {
42
+ this . namedButtons = this . namedButtons . concat ( items . splice ( 0 , 6 ) ) ;
43
+ } else if ( this . mediaService . isActive ( 'md' ) ) {
44
+ this . namedButtons = this . namedButtons . concat ( items . splice ( 0 , 8 ) ) ;
45
+ } else if ( this . mediaService . isActive ( 'lg' ) ) {
46
+ this . namedButtons = this . namedButtons . concat ( items . splice ( 0 , 12 ) ) ;
47
+ } else if ( this . mediaService . isActive ( 'xl' ) ) {
48
+ this . namedButtons = this . namedButtons . concat ( items . splice ( 0 , 16 ) ) ;
49
+ }
49
50
50
- if ( items . length > 0 ) {
51
- this . overflowMenuItems = items ;
51
+ if ( items . length > 0 ) {
52
+ this . overflowMenuItems = items ;
53
+ }
52
54
}
53
55
}
54
56
}
0 commit comments