Skip to content

Commit

Permalink
Fixed #4850 - PickList OrderList | Keyboard Support Enhancements
Browse files Browse the repository at this point in the history
  • Loading branch information
yigitfindikli committed Nov 20, 2023
1 parent 20a818b commit a5a4f62
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
18 changes: 17 additions & 1 deletion components/lib/orderlist/OrderList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ export default {
if (event.ctrlKey) {
this.d_selection = [...this.modelValue];
this.$emit('update:selection', this.d_selection);
event.preventDefault();
}
default:
Expand Down Expand Up @@ -227,6 +229,10 @@ export default {
this.d_selection = [...this.modelValue].slice(0, matchedOptionIndex + 1);
this.$emit('update:selection', this.d_selection);
this.$emit('selection-change', {
originalEvent: event,
value: this.d_selection
});
} else {
this.changeFocusedOptionIndex(0);
}
Expand All @@ -241,6 +247,10 @@ export default {
this.d_selection = [...this.modelValue].slice(matchedOptionIndex, items.length);
this.$emit('update:selection', this.d_selection);
this.$emit('selection-change', {
originalEvent: event,
value: this.d_selection
});
} else {
this.changeFocusedOptionIndex(DomHandler.find(this.list, '[data-pc-section="item"]').length - 1);
}
Expand All @@ -257,14 +267,20 @@ export default {
event.preventDefault();
},
onSpaceKey(event) {
if (event.shiftKey) {
event.preventDefault();
if (event.shiftKey && this.d_selection && this.d_selection.length > 0) {
const items = DomHandler.find(this.list, '[data-pc-section="item"]');
const selectedItemIndex = ObjectUtils.findIndexInList(this.d_selection[0], [...this.modelValue]);
const focusedItem = DomHandler.findSingle(this.list, `[data-pc-section="item"][id=${this.focusedOptionIndex}]`);
const matchedOptionIndex = [...items].findIndex((item) => item === focusedItem);
this.d_selection = [...this.modelValue].slice(Math.min(selectedItemIndex, matchedOptionIndex), Math.max(selectedItemIndex, matchedOptionIndex) + 1);
this.$emit('update:selection', this.d_selection);
this.$emit('selection-change', {
originalEvent: event,
value: this.d_selection
});
} else {
this.onEnterKey(event);
}
Expand Down
16 changes: 15 additions & 1 deletion components/lib/picklist/PickList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,8 @@ export default {
if (event.ctrlKey) {
this.d_selection = [...this.modelValue];
this.$emit('update:selection', this.d_selection);
event.preventDefault();
}
default:
Expand Down Expand Up @@ -658,7 +660,7 @@ export default {
onSpaceKey(event, listType) {
event.preventDefault();
if (event.shiftKey) {
if (event.shiftKey && this.d_selection && this.d_selection.length > 0) {
const listId = listType === 'sourceList' ? 0 : 1;
const items = DomHandler.find(this.$refs[listType].$el, '[data-pc-section="item"]');
const selectedItemIndex = ObjectUtils.findIndexInList(this.d_selection[listId][0], [...this.modelValue[listId]]);
Expand All @@ -667,6 +669,10 @@ export default {
this.d_selection[listId] = [...this.modelValue[listId]].slice(Math.min(selectedItemIndex, matchedOptionIndex), Math.max(selectedItemIndex, matchedOptionIndex) + 1);
this.$emit('update:selection', this.d_selection);
this.$emit('selection-change', {
originalEvent: event,
value: this.d_selection
});
} else {
this.onEnterKey(event, listType);
}
Expand All @@ -680,6 +686,10 @@ export default {
this.d_selection[listId] = [...this.modelValue[listId]].slice(0, matchedOptionIndex + 1);
this.$emit('update:selection', this.d_selection);
this.$emit('selection-change', {
originalEvent: event,
value: this.d_selection
});
} else {
this.changeFocusedOptionIndex(0, listType);
}
Expand All @@ -696,6 +706,10 @@ export default {
this.d_selection[listId] = [...this.modelValue[listId]].slice(matchedOptionIndex, items.length);
this.$emit('update:selection', this.d_selection);
this.$emit('selection-change', {
originalEvent: event,
value: this.d_selection
});
} else {
this.changeFocusedOptionIndex(items.length - 1, listType);
}
Expand Down

0 comments on commit a5a4f62

Please sign in to comment.