mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Only show dock toggle buttons when dragging if item is allowed
This commit is contained in:
14
src/dock.js
14
src/dock.js
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user