Browse Source

fix undefined buttons

yogevbd 6 years ago
parent
commit
e3b4d15a06
1 changed files with 7 additions and 5 deletions
  1. 7
    5
      lib/src/commands/LayoutTreeCrawler.ts

+ 7
- 5
lib/src/commands/LayoutTreeCrawler.ts View File

63
       this._normalizeButtons(passedOptions.topBar.leftButtons, (buttons, style) => {
63
       this._normalizeButtons(passedOptions.topBar.leftButtons, (buttons, style) => {
64
         passedOptions.topBar.leftButtons = buttons;
64
         passedOptions.topBar.leftButtons = buttons;
65
 
65
 
66
-        if (staticOptions.topBar && buttons) {
66
+        if (staticOptions.topBar) {
67
           this._applyButtonsStyle(staticOptions.topBar.leftButtons, style);
67
           this._applyButtonsStyle(staticOptions.topBar.leftButtons, style);
68
         }
68
         }
69
       });
69
       });
71
       this._normalizeButtons(passedOptions.topBar.rightButtons, (buttons, style) => {
71
       this._normalizeButtons(passedOptions.topBar.rightButtons, (buttons, style) => {
72
         passedOptions.topBar.rightButtons = buttons;
72
         passedOptions.topBar.rightButtons = buttons;
73
 
73
 
74
-        if (staticOptions.topBar && buttons) {
74
+        if (staticOptions.topBar) {
75
           this._applyButtonsStyle(staticOptions.topBar.rightButtons, style);
75
           this._applyButtonsStyle(staticOptions.topBar.rightButtons, style);
76
         }
76
         }
77
       });
77
       });
87
   }
87
   }
88
 
88
 
89
   _applyButtonsStyle(buttons, style) {
89
   _applyButtonsStyle(buttons, style) {
90
-    buttons.forEach((button) => {
91
-      _.merge(button, style);
92
-    });
90
+    if (buttons) {
91
+      buttons.forEach((button) => {
92
+        _.merge(button, style);
93
+      });
94
+    }
93
   }
95
   }
94
 
96
 
95
   _assertKnownLayoutType(type) {
97
   _assertKnownLayoutType(type) {