@@ -9,8 +9,8 @@ import {Subscription} from 'rxjs';
99 styleUrls : [ './button-bar.component.scss' ]
1010} )
1111export class ButtonBarComponent implements OnInit , OnDestroy {
12- @Input ( ) navItems : NavItem [ ] ;
13- watcher : Subscription ;
12+ @Input ( ) navItems : NavItem [ ] | undefined ;
13+ watcher : Subscription | undefined ;
1414 namedButtons : NavItem [ ] = [ ] ;
1515 iconButtons : NavItem [ ] = [ ] ;
1616 overflowMenuItems : NavItem [ ] = [ ] ;
@@ -30,25 +30,27 @@ export class ButtonBarComponent implements OnInit, OnDestroy {
3030 }
3131
3232 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 = [ ] ;
3738
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+ }
4950
50- if ( items . length > 0 ) {
51- this . overflowMenuItems = items ;
51+ if ( items . length > 0 ) {
52+ this . overflowMenuItems = items ;
53+ }
5254 }
5355 }
5456}
0 commit comments