From 854c3362a23bc726e56eecf20e5d5f15e3325903 Mon Sep 17 00:00:00 2001 From: tugcekucukoglu Date: Wed, 24 Jan 2024 18:04:26 +0300 Subject: [PATCH] Fix mousedown event --- components/lib/orderlist/OrderList.vue | 10 +++++----- components/lib/picklist/PickList.vue | 9 +++++---- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/components/lib/orderlist/OrderList.vue b/components/lib/orderlist/OrderList.vue index ba83b4a6f..dc16a0ed0 100755 --- a/components/lib/orderlist/OrderList.vue +++ b/components/lib/orderlist/OrderList.vue @@ -62,7 +62,7 @@ :class="cx('item', { item, id: `${id}_${i}` })" @click="onItemClick($event, item, i)" @touchend="onItemTouchEnd" - @mousedown="onOptionMouseDown(i)" + @mousedown="onOptionMouseDown($event, i)" @mousemove="onOptionMouseMove(i)" :aria-selected="isSelected(item)" v-bind="getPTOptions(item, 'item', i)" @@ -188,9 +188,10 @@ export default { break; } }, - onOptionMouseDown(index) { + onOptionMouseDown(event, index) { this.focused = true; - this.focusedOptionIndex = index; + this.focusedOptionIndex = `${this.id}_${index}`; + event.preventDefault(); }, onOptionMouseMove(index) { if (this.focusOnHover && this.focused) { @@ -455,10 +456,9 @@ export default { const selectedIndex = ObjectUtils.findIndexInList(item, this.d_selection); const selected = selectedIndex != -1; const metaSelection = this.itemTouched ? false : this.metaKeySelection; - const selectedId = this.findAllItems()[index].getAttribute('id'); - this.focusedOptionIndex = event?.type === 'click' ? -1 : selectedId; + this.focusedOptionIndex = selectedId; if (metaSelection) { const metaKey = event.metaKey || event.ctrlKey; diff --git a/components/lib/picklist/PickList.vue b/components/lib/picklist/PickList.vue index c30618785..68f843d5f 100755 --- a/components/lib/picklist/PickList.vue +++ b/components/lib/picklist/PickList.vue @@ -70,7 +70,7 @@ @click="onItemClick($event, item, i, 0)" @dblclick="onItemDblClick($event, item, 0)" @touchend="onItemTouchEnd" - @mousedown="onOptionMouseDown(i, 'sourceList')" + @mousedown="onOptionMouseDown($event, i, 'sourceList')" @mousemove="onOptionMouseMove(i, 'sourceList')" role="option" :aria-selected="isSelected(item, 0)" @@ -162,7 +162,7 @@ @click="onItemClick($event, item, i, 1)" @dblclick="onItemDblClick($event, item, 1)" @keydown="onItemKeyDown($event, 'targetList')" - @mousedown="onOptionMouseDown(i, 'targetList')" + @mousedown="onOptionMouseDown($event, i, 'targetList')" @mousemove="onOptionMouseMove(i, 'targetList')" @touchend="onItemTouchEnd" role="option" @@ -311,9 +311,10 @@ export default { this.focusedOptionIndex = -1; this.$emit('blur', event); }, - onOptionMouseDown(index, listType) { + onOptionMouseDown(event, index, listType) { this.focused[listType] = true; this.focusedOptionIndex = index; + event.preventDefault(); }, onOptionMouseMove(index, listType) { if (this.focusOnHover && this.focused[listType]) { @@ -582,7 +583,7 @@ export default { const metaSelection = this.itemTouched ? false : this.metaKeySelection; const selectedId = DomHandler.find(this.$refs[listType].$el, '[data-pc-section="item"]')[index].getAttribute('id'); - this.focusedOptionIndex = event?.type === 'click' ? -1 : selectedId; + this.focusedOptionIndex = selectedId; let _selection; if (metaSelection) {