Only show dock toggle buttons when dragging if item is allowed

This commit is contained in:
Matthew Dapena-Tretter
2017-03-27 15:09:32 -07:00
parent f3c3917825
commit 41953ae7d6
2 changed files with 15 additions and 5 deletions

View File

@@ -192,9 +192,11 @@ module.exports = class Dock {
this.resizeHandle.update({dockIsOpen: this.state.open})
this.toggleButton.update({
open: shouldBeVisible,
// Don't show the toggle button if the dock is closed and empty.
visible: (state.hovered && (this.state.open || this.getPaneItems().length > 0)) ||
(state.draggingItem && !shouldBeVisible)
visible:
// Don't show the toggle button if the dock is closed and empty...
(state.hovered && (this.state.open || this.getPaneItems().length > 0)) ||
// ...or if the item can't be dropped in that dock.
(!shouldBeVisible && state.draggingItem && isItemAllowed(state.draggingItem, this.location))
})
}
@@ -749,3 +751,9 @@ function rectContainsPoint (rect, point) {
point.y <= rect.bottom
)
}
// Is the item allowed in the given location?
function isItemAllowed (item, location) {
if (typeof item.getAllowedLocations !== 'function') return true
return item.getAllowedLocations().includes(location)
}