diff --git a/components/orderlist/OrderList.vue b/components/orderlist/OrderList.vue index 30c119e22..9e04cd6c7 100755 --- a/components/orderlist/OrderList.vue +++ b/components/orderlist/OrderList.vue @@ -31,7 +31,7 @@ v-bind="listProps" > @@ -148,9 +148,12 @@ export default { }, onListFocus(event) { const selectedFirstItem = DomHandler.findSingle(this.list, 'li.p-orderlist-item.p-highlight'); - const index = selectedFirstItem ? ObjectUtils.findIndexInList(selectedFirstItem, this.list.children) : '0'; + const findIndex = ObjectUtils.findIndexInList(selectedFirstItem, this.list.children); this.focused = true; + + const index = this.focusedOptionIndex !== -1 ? this.focusedOptionIndex : selectedFirstItem ? findIndex : -1; + this.changeFocusedOptionIndex(index); this.$emit('focus', event); }, @@ -195,6 +198,10 @@ export default { break; } }, + onOptionMouseDown(index) { + this.focused = true; + this.focusedOptionIndex = index; + }, onArrowDownKey(event) { const optionIndex = this.findNextOptionIndex(this.focusedOptionIndex); diff --git a/components/picklist/PickList.vue b/components/picklist/PickList.vue index 66a9684dd..9566038b4 100755 --- a/components/picklist/PickList.vue +++ b/components/picklist/PickList.vue @@ -36,6 +36,7 @@ @click="onItemClick($event, item, i, 0)" @dblclick="onItemDblClick($event, item, 0)" @touchend="onItemTouchEnd" + @mousedown="onOptionMouseDown(i, 'sourceList')" role="option" :aria-selected="isSelected(item, 0)" > @@ -80,6 +81,7 @@ @click="onItemClick($event, item, i, 1)" @dblclick="onItemDblClick($event, item, 1)" @keydown="onItemKeyDown($event, 'targetList')" + @mousedown="onOptionMouseDown(i, 'targetList')" @touchend="onItemTouchEnd" role="option" :aria-selected="isSelected(item, 1)" @@ -236,9 +238,12 @@ export default { }, onListFocus(event, listType) { const selectedFirstItem = DomHandler.findSingle(this.$refs[listType].$el, 'li.p-picklist-item.p-highlight'); - const index = selectedFirstItem ? ObjectUtils.findIndexInList(selectedFirstItem, this.$refs[listType].$el.children) : '0'; + const findIndex = ObjectUtils.findIndexInList(selectedFirstItem, this.$refs[listType].$el.children); this.focused[listType] = true; + + const index = this.focusedOptionIndex !== -1 ? this.focusedOptionIndex : selectedFirstItem ? findIndex : -1; + this.changeFocusedOptionIndex(index, listType); this.$emit('focus', event); }, @@ -247,6 +252,10 @@ export default { this.focusedOptionIndex = -1; this.$emit('blur', event); }, + onOptionMouseDown(index, listType) { + this.focused[listType] = true; + this.focusedOptionIndex = index; + }, moveUp(event, listIndex) { if (this.d_selection && this.d_selection[listIndex]) { let valueList = [...this.modelValue[listIndex]];