diff --git a/spec/workspace-element-spec.js b/spec/workspace-element-spec.js index 2576cd432..d3027e574 100644 --- a/spec/workspace-element-spec.js +++ b/spec/workspace-element-spec.js @@ -480,6 +480,26 @@ describe('WorkspaceElement', () => { }) ) }) + + describe('::moveActiveItemToNearestPaneInDirection(direction, params)', () => { + describe('when the item is not allowed in nearest pane in the given direction', () => { + it('does not move or copy the active item', function () { + const item = { + element: document.createElement('div'), + getAllowedLocations: () => ['left', 'right'], + } + + workspace.getBottomDock().show() + startingPane.activate() + startingPane.activateItem(item) + workspaceElement.moveActiveItemToNearestPaneInDirection('below', {keepOriginal: false}) + expect(workspace.paneForItem(item)).toBe(startingPane) + + workspaceElement.moveActiveItemToNearestPaneInDirection('below', {keepOriginal: true}) + expect(workspace.paneForItem(item)).toBe(startingPane) + }) + }) + }) }) describe('mousing over docks', () => { diff --git a/src/pane-container.js b/src/pane-container.js index 88922c000..c4cb033a8 100644 --- a/src/pane-container.js +++ b/src/pane-container.js @@ -213,12 +213,22 @@ class PaneContainer { moveActiveItemToPane (destPane) { const item = this.activePane.getActiveItem() + + if (typeof item.getAllowedLocations === 'function' && !item.getAllowedLocations().includes(destPane.getContainer().getLocation())) { + return + } + this.activePane.moveItemToPane(item, destPane) destPane.setActiveItem(item) } copyActiveItemToPane (destPane) { const item = this.activePane.copyActiveItem() + + if (typeof item.getAllowedLocations === 'function' && !item.getAllowedLocations().includes(destPane.getContainer().getLocation())) { + return + } + destPane.activateItem(item) }