Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
Merge pull request #11185 from bsclifton/fix-phantom-tab-crashes
Browse files Browse the repository at this point in the history
Fix phantom tab crashes
  • Loading branch information
bsclifton committed Sep 27, 2017
1 parent 1636e26 commit 765a315
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
22 changes: 13 additions & 9 deletions app/renderer/components/tabs/tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

This comment has been minimized.

Copy link
@bsclifton

bsclifton Sep 27, 2017

Author Member

cc: @cezaraugusto

I had added this check since there are conditions where this.frame is null/undefined. They are edge cases, but wanted you to review to make sure I did the right thing 😄

This comment has been minimized.

Copy link
@cezaraugusto

cezaraugusto Sep 28, 2017

Contributor

thanks, works great.

// 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 () {
Expand All @@ -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) {
Expand Down
11 changes: 9 additions & 2 deletions js/contextMenus.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'))]
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 765a315

Please sign in to comment.