Fixed #5099 - autoOptionFocus property added to Input-like components

This commit is contained in:
tugcekucukoglu 2024-01-17 17:09:34 +03:00
parent c8609171c2
commit 54a7a4fb50
10 changed files with 60 additions and 13 deletions

View file

@ -140,18 +140,19 @@ export default {
return ObjectUtils.findIndexInList(item, this.d_selection) != -1;
},
onListFocus(event) {
const selectedFirstItem = DomHandler.findSingle(this.list, '[data-p-highlight="true"]') || DomHandler.findSingle(this.list, '[data-pc-section="item"]');
this.focused = true;
const selectedFirstItem = this.autoOptionFocus
? DomHandler.findSingle(this.list, '[data-p-highlight="true"]') || DomHandler.findSingle(this.list, '[data-pc-section="item"]')
: DomHandler.findSingle(this.list, '[data-p-highlight="true"]');
if (selectedFirstItem) {
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);
}
this.$emit('focus', event);
},
onListBlur(event) {
this.focused = false;