diff --git a/apps/common/main/lib/controller/Themes.js b/apps/common/main/lib/controller/Themes.js index 175ca5a2f..e96739acf 100644 --- a/apps/common/main/lib/controller/Themes.js +++ b/apps/common/main/lib/controller/Themes.js @@ -255,7 +255,9 @@ define([ $(window).on('storage', function (e) { if ( e.key == 'ui-theme' || e.key == 'ui-theme-id' ) { - me.setTheme(e.originalEvent.newValue, true); + if ( !!t.originalEvent.newValue ) { + me.setTheme(t.originalEvent.newValue, true); + } } else if ( e.key == 'content-theme' ) { me.setContentTheme(e.originalEvent.newValue, true); @@ -371,6 +373,8 @@ define([ }, setTheme: function (obj, force) { + if ( !obj ) return; + var id = get_ui_theme_name(obj); if ( (this.currentThemeId() != id || force) && !!themes_map[id] ) { document.body.className = document.body.className.replace(/theme-[\w-]+\s?/gi, '').trim(); diff --git a/apps/documenteditor/main/app/controller/Viewport.js b/apps/documenteditor/main/app/controller/Viewport.js index 5edcbdb35..3ea1a59c3 100644 --- a/apps/documenteditor/main/app/controller/Viewport.js +++ b/apps/documenteditor/main/app/controller/Viewport.js @@ -372,12 +372,14 @@ define([ onThemeChanged: function (id) { var document = DE.getController('Main').document; if ( !/^pdf|djvu|xps|oxps$/.test(document.fileType) ) { - var current_dark = Common.UI.Themes.isDarkTheme(); - var menuItem = this.header.menuItemsDarkMode; - menuItem.setVisible(current_dark); - menuItem.$el.prev('.divider')[current_dark ? 'show' : 'hide'](); + if ( this.header.menuItemsDarkMode ) { + var current_dark = Common.UI.Themes.isDarkTheme(); + var menuItem = this.header.menuItemsDarkMode; + menuItem.setVisible(current_dark); + menuItem.$el.prev('.divider')[current_dark ? 'show' : 'hide'](); - menuItem.setChecked(Common.UI.Themes.isContentThemeDark()); + menuItem.setChecked(Common.UI.Themes.isContentThemeDark()); + } } },