Skip to content

Commit

Permalink
fix: #7026, Select: Editable Dropdown search not working as expected
Browse files Browse the repository at this point in the history
  • Loading branch information
ANTONA09 committed Dec 30, 2024
1 parent aec97b2 commit aa3f5c0
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions packages/primevue/src/select/Select.vue
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,10 @@ export default {
hasFocusableElements() {
return getFocusableElements(this.overlay, ':not([data-p-hidden-focusable="true"])').length > 0;
},
isOptionMatched(option) {
isOptionExactMatched(option) {
return this.isValidOption(option) && typeof this.getOptionLabel(option) === 'string' && this.getOptionLabel(option)?.toLocaleLowerCase(this.filterLocale) == this.searchValue.toLocaleLowerCase(this.filterLocale);
},
isOptionStartsWith(option) {
return this.isValidOption(option) && typeof this.getOptionLabel(option) === 'string' && this.getOptionLabel(option)?.toLocaleLowerCase(this.filterLocale).startsWith(this.searchValue.toLocaleLowerCase(this.filterLocale));
},
isValidOption(option) {
Expand Down Expand Up @@ -846,11 +849,10 @@ export default {
let matched = false;
if (isNotEmpty(this.searchValue)) {
if (this.focusedOptionIndex !== -1) {
optionIndex = this.visibleOptions.slice(this.focusedOptionIndex).findIndex((option) => this.isOptionMatched(option));
optionIndex = optionIndex === -1 ? this.visibleOptions.slice(0, this.focusedOptionIndex).findIndex((option) => this.isOptionMatched(option)) : optionIndex + this.focusedOptionIndex;
} else {
optionIndex = this.visibleOptions.findIndex((option) => this.isOptionMatched(option));
optionIndex = this.visibleOptions.findIndex((option) => this.isOptionExactMatched(option));
if (optionIndex === -1) {
optionIndex = this.visibleOptions.findIndex((option) => this.isOptionStartsWith(option));
}
if (optionIndex !== -1) {
Expand Down

0 comments on commit aa3f5c0

Please sign in to comment.