Skip to content

Commit

Permalink
Merge pull request brave#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 authored and syuan100 committed Nov 9, 2017
1 parent 393fb75 commit 116245e
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) {
// 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 @@ -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'))]
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 116245e

Please sign in to comment.