Skip to content

Commit

Permalink
Sitemap treeview: Fix arrows/chevrons shown if not expandable (#3007)
Browse files Browse the repository at this point in the history
Regression from #2904.
Reported in #2970 (comment).

Signed-off-by: Florian Hotze <[email protected]>
  • Loading branch information
florian-h05 authored Jan 13, 2025
1 parent 54a3498 commit 7ef5b6f
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
:textColor="iconColor" :color="'blue'"
:selected="selected && selected === widget"
:opened="!widget.closed"
:toggle="canHaveChildren"
@treeview:open="setWidgetClosed(false)"
@treeview:close="setWidgetClosed(true)"
@click="select">
<draggable v-if="canHaveChildren" :list="children" group="sitemap-treeview" animation="150" fallbackOnBody="true" swapThreshold="0.6"
<draggable :list="children" group="sitemap-treeview" animation="150" fallbackOnBody="true" swapThreshold="0.6"
@start="onStart" @change="onChange" @end="onEnd">
<sitemap-treeview-item class="sitemap-treeview-item" v-for="(childwidget, idx) in children"
:key="idx"
Expand Down Expand Up @@ -66,18 +67,21 @@ export default {
},
onStart (event) {
console.debug('Drag start event:', event)
this.$set(this.localMoveState, 'moving', true)
this.$set(this.localMoveState, 'widget', this.widget.slots.widgets[event.oldIndex])
this.$set(this.localMoveState, 'oldList', this.widget.slots.widgets)
this.$set(this.localMoveState, 'oldIndex', event.oldIndex)
},
onChange (event) {
console.debug('Drag change event:', event)
if (event.added) {
this.$set(this.localMoveState, 'moving', false)
this.validateMove(event.added.newIndex)
}
},
onEnd (event) {
console.debug('Drag end event:', event)
this.$set(this.localMoveState, 'moving', false)
this.validateMove(event.newIndex)
},
validateMove (newIndex) {
Expand Down Expand Up @@ -123,7 +127,7 @@ export default {
return this.widget.slots?.widgets || []
},
canHaveChildren () {
return this.LINKABLE_WIDGET_TYPES.includes(this.widget.component)
return (this.LINKABLE_WIDGET_TYPES.includes(this.widget.component) && (this.children.length > 0 || this.localMoveState.moving)) === true
}
}
}
Expand Down

0 comments on commit 7ef5b6f

Please sign in to comment.