diff --git a/app/renderer/components/tabs/tab.js b/app/renderer/components/tabs/tab.js index 485b88b4914..034b3cc8853 100644 --- a/app/renderer/components/tabs/tab.js +++ b/app/renderer/components/tabs/tab.js @@ -122,14 +122,16 @@ class Tab extends React.Component { } onDragStart (e) { - // showing up the sentinel while dragging leads to show the shadow - // of the next tab. See 10691#issuecomment-329854096 - // this is added back to original size when onDrag event is happening - this.tabSentinel.style.width = 0 - - dnd.onDragStart(dragTypes.TAB, this.frame, e) - // cancel tab preview while dragging. see #10103 - windowActions.setTabHoverState(this.props.frameKey, false, false) + if (this.frame) { + // showing up the sentinel while dragging leads to show the shadow + // of the next tab. See 10691#issuecomment-329854096 + // this is added back to original size when onDrag event is happening + this.tabSentinel.style.width = 0 + + dnd.onDragStart(dragTypes.TAB, this.frame, e) + // cancel tab preview while dragging. see #10103 + windowActions.setTabHoverState(this.props.frameKey, false, false) + } } onDrag () { @@ -138,7 +140,9 @@ class Tab extends React.Component { } onDragEnd (e) { - dnd.onDragEnd(dragTypes.TAB, this.frame, e) + if (this.frame) { + dnd.onDragEnd(dragTypes.TAB, this.frame, e) + } } onDragOver (e) { diff --git a/js/contextMenus.js b/js/contextMenus.js index cf63d87e1fa..0777e1f6dc3 100644 --- a/js/contextMenus.js +++ b/js/contextMenus.js @@ -426,6 +426,10 @@ function autofillTemplateInit (suggestions, frame) { } function tabTemplateInit (frameProps) { + if (!frameProps) { + return null + } + const frameKey = frameProps.get('key') const tabId = frameProps.get('tabId') const template = [CommonMenu.newTabMenuItem(frameProps.get('tabId'))] @@ -1274,8 +1278,11 @@ function onMainContextMenu (nodeProps, frame, tab, contextMenuType) { function onTabContextMenu (frameProps, e) { e.stopPropagation() - const tabMenu = Menu.buildFromTemplate(tabTemplateInit(frameProps)) - tabMenu.popup(getCurrentWindow()) + const template = tabTemplateInit(frameProps) + if (template) { + const tabMenu = Menu.buildFromTemplate(template) + tabMenu.popup(getCurrentWindow()) + } } function onNewTabContextMenu (target) {