diff --git a/js/components/longPressButton.js b/js/components/longPressButton.js index 2de74c58a13..751ac6658d5 100644 --- a/js/components/longPressButton.js +++ b/js/components/longPressButton.js @@ -19,11 +19,24 @@ class LongPressButton extends ImmutableComponent { if (e.target.attributes.getNamedItem('disabled')) { return } + if (e && e.preventDefault) { + e.preventDefault() + } + if (e && e.stopPropagation) { + e.stopPropagation() + } const self = this const target = e.target const LONG_PRESS_MILLISECONDS = 300 + // Right click should immediately trigger the action + if (e.button === 2) { + self.props.onLongPress(target) + return + } + + // Otherwise, it should wait before triggering this.longPressTimer = setTimeout(function () { self.isLocked = true self.props.onLongPress(target) @@ -49,7 +62,9 @@ class LongPressButton extends ImmutableComponent { this.isLocked = false return } - this.props.onClick(e) + if (this.props.onClick) { + this.props.onClick(e) + } } render () { diff --git a/js/components/tabs.js b/js/components/tabs.js index 61b55980dc7..1537f096b38 100644 --- a/js/components/tabs.js +++ b/js/components/tabs.js @@ -11,8 +11,9 @@ const windowActions = require('../actions/windowActions') const windowStore = require('../stores/windowStore') const dragTypes = require('../constants/dragTypes') const cx = require('../lib/classSet') +const contextMenus = require('../contextMenus') -const Button = require('./button') +const LongPressButton = require('./longPressButton') const Tab = require('./tab') const dnd = require('../dnd') const dndData = require('../dndData') @@ -24,6 +25,8 @@ class Tabs extends ImmutableComponent { this.onDrop = this.onDrop.bind(this) this.onPrevPage = this.onPrevPage.bind(this) this.onNextPage = this.onNextPage.bind(this) + this.onNewTabLongPress = this.onNewTabLongPress.bind(this) + this.wasNewTabClicked = this.wasNewTabClicked.bind(this) } onPrevPage () { @@ -82,11 +85,15 @@ class Tabs extends ImmutableComponent { e.preventDefault() } } - + wasNewTabClicked (target) { + return target.className === this.refs.newTabButton.props.className + } newTab () { windowActions.newFrame() } - + onNewTabLongPress (target) { + contextMenus.onNewTabContextMenu(target) + } render () { this.tabRefs = [] const index = this.props.previewTabPageIndex !== undefined @@ -125,10 +132,16 @@ class Tabs extends ImmutableComponent { onClick={this.onNextPage} /> } })()} -