Skip to content

Commit

Permalink
fix: Closing tab with middle mouse on Linux pasting into active editor (
Browse files Browse the repository at this point in the history
#2240)

Fixes #1461
  • Loading branch information
mattrunyon authored Oct 1, 2024
1 parent aad0aa6 commit 91bd8fe
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions packages/golden-layout/src/controls/Tab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export default class Tab {

this.element.on('click', this._onTabClick);
this.element.on('auxclick', this._onTabClick);
this.element.on('mouseup', this._onMouseUp);

if (this.contentItem.config.isClosable) {
this.closeElement.on('click', this._onCloseClick);
Expand Down Expand Up @@ -128,6 +129,7 @@ export default class Tab {
_$destroy() {
this.element.off('click', this._onTabClick);
this.element.off('auxclick', this._onTabClick);
this.element.off('mouseup', this._onMouseUp);
this.closeElement.off('click', this._onCloseClick);
if (isComponent(this.contentItem)) {
this.contentItem.container._contentElement.off();
Expand Down Expand Up @@ -270,6 +272,18 @@ export default class Tab {
}
}

/**
* Callback to prevent paste into active input on Linux
* when closing a tab via middle click.
* @param event
*/
_onMouseUp(event: JQuery.TriggeredEvent) {
if (event.button === 1) {
event.preventDefault(); // This seems to prevent the paste event from firing
event.stopPropagation(); // Stop propagation just in case
}
}

/**
* Callback to capture tab close button mousedown
* to prevent tab from activating.
Expand Down

0 comments on commit 91bd8fe

Please sign in to comment.