Skip to content

Commit

Permalink
Make drop on root work
Browse files Browse the repository at this point in the history
  • Loading branch information
lookacat committed May 26, 2023
1 parent 4c4d72a commit 6625b78
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
@dragenter.prevent="dropItemStyling(index, false, $event)"
@dragleave.prevent="dropItemStyling(index, true, $event)"
@mouseleave="dropItemStyling(index, true, $event)"
@drop="dropItemEvent(item.to)"
@drop="dropItemEvent(item.to, index)"
>
<router-link v-if="item.to" :aria-current="getAriaCurrent(index)" :to="item.to">
<span>{{ item.text }}</span>
Expand Down Expand Up @@ -174,7 +174,11 @@ export default defineComponent({
event.preventDefault()
}
const dropItemEvent = (item) => {
const dropItemEvent = (item, index) => {
if (index === unref(displayItems).length - 1) {
return
}
item.path = item.path ? item.path : '/'
emit(EVENT_ITEM_DROPPED_BREADCRUMB, item)
}
Expand Down Expand Up @@ -266,6 +270,9 @@ export default defineComponent({
}
const dropItemStyling = (key, leaving, event) => {
if (key === unref(displayItems).length - 1) {
return
}
const hasFilePayload = (event.dataTransfer?.types || []).some((e) => e === 'Files')
if (hasFilePayload) return
if (event.currentTarget?.contains(event.relatedTarget)) {
Expand Down

0 comments on commit 6625b78

Please sign in to comment.