From 765a3157fa36f446bf8fc184956e72ec3297bd1e Mon Sep 17 00:00:00 2001 From: Brian Clifton Date: Wed, 27 Sep 2017 14:43:01 -0700 Subject: [PATCH] Merge pull request #11185 from bsclifton/fix-phantom-tab-crashes Fix phantom tab crashes --- app/renderer/components/tabs/tab.js | 22 +++++++++++++--------- js/contextMenus.js | 11 +++++++++-- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/app/renderer/components/tabs/tab.js b/app/renderer/components/tabs/tab.js index 0969e43441f..b0c22a6fefd 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 3098aa70977..4fffd1d5f12 100644 --- a/js/contextMenus.js +++ b/js/contextMenus.js @@ -378,6 +378,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'))] @@ -1211,8 +1215,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) {