diff --git a/src/components/autocomplete/AutoComplete.vue b/src/components/autocomplete/AutoComplete.vue index ef1410925..1162a6a78 100755 --- a/src/components/autocomplete/AutoComplete.vue +++ b/src/components/autocomplete/AutoComplete.vue @@ -738,14 +738,14 @@ export default { return this.visibleOptions.findIndex(option => this.isValidOption(option)); }, findLastOptionIndex() { - return this.visibleOptions.findLastIndex(option => this.isValidOption(option)); + return ObjectUtils.findLastIndex(this.visibleOptions, option => this.isValidOption(option)); }, findNextOptionIndex(index) { const matchedOptionIndex = index < (this.visibleOptions.length - 1) ? this.visibleOptions.slice(index + 1).findIndex(option => this.isValidOption(option)) : -1; return matchedOptionIndex > -1 ? matchedOptionIndex + index + 1 : index; }, findPrevOptionIndex(index) { - const matchedOptionIndex = index > 0 ? this.visibleOptions.slice(0, index).findLastIndex(option => this.isValidOption(option)) : -1; + const matchedOptionIndex = index > 0 ? ObjectUtils.findLastIndex(this.visibleOptions.slice(0, index), option => this.isValidOption(option)) : -1; return matchedOptionIndex > -1 ? matchedOptionIndex : index; }, findSelectedOptionIndex() { diff --git a/src/components/cascadeselect/CascadeSelect.vue b/src/components/cascadeselect/CascadeSelect.vue index e16e3213f..3f0d021bd 100644 --- a/src/components/cascadeselect/CascadeSelect.vue +++ b/src/components/cascadeselect/CascadeSelect.vue @@ -547,14 +547,14 @@ export default { return this.visibleOptions.findIndex(processedOption => this.isValidOption(processedOption)); }, findLastOptionIndex() { - return this.visibleOptions.findLastIndex(processedOption => this.isValidOption(processedOption)); + return ObjectUtils.findLastIndex(this.visibleOptions, processedOption => this.isValidOption(processedOption)); }, findNextOptionIndex(index) { const matchedOptionIndex = index < (this.visibleOptions.length - 1) ? this.visibleOptions.slice(index + 1).findIndex(processedOption => this.isValidOption(processedOption)) : -1; return matchedOptionIndex > -1 ? matchedOptionIndex + index + 1 : index; }, findPrevOptionIndex(index) { - const matchedOptionIndex = index > 0 ? this.visibleOptions.slice(0, index).findLastIndex(processedOption => this.isValidOption(processedOption)) : -1; + const matchedOptionIndex = index > 0 ? ObjectUtils.findLastIndex(this.visibleOptions.slice(0, index), processedOption => this.isValidOption(processedOption)) : -1; return matchedOptionIndex > -1 ? matchedOptionIndex : index; }, findSelectedOptionIndex() { diff --git a/src/components/dropdown/Dropdown.vue b/src/components/dropdown/Dropdown.vue index 4aa6bcb27..55e37ae96 100755 --- a/src/components/dropdown/Dropdown.vue +++ b/src/components/dropdown/Dropdown.vue @@ -678,14 +678,14 @@ export default { return this.visibleOptions.findIndex(option => this.isValidOption(option)); }, findLastOptionIndex() { - return this.visibleOptions.findLastIndex(option => this.isValidOption(option)); + return ObjectUtils.findLastIndex(this.visibleOptions, option => this.isValidOption(option)); }, findNextOptionIndex(index) { const matchedOptionIndex = index < (this.visibleOptions.length - 1) ? this.visibleOptions.slice(index + 1).findIndex(option => this.isValidOption(option)) : -1; return matchedOptionIndex > -1 ? matchedOptionIndex + index + 1 : index; }, findPrevOptionIndex(index) { - const matchedOptionIndex = index > 0 ? this.visibleOptions.slice(0, index).findLastIndex(option => this.isValidOption(option)) : -1; + const matchedOptionIndex = index > 0 ? ObjectUtils.findLastIndex(this.visibleOptions.slice(0, index), option => this.isValidOption(option)) : -1; return matchedOptionIndex > -1 ? matchedOptionIndex : index; }, findSelectedOptionIndex() { diff --git a/src/components/listbox/Listbox.vue b/src/components/listbox/Listbox.vue index 448960421..0cdece29c 100755 --- a/src/components/listbox/Listbox.vue +++ b/src/components/listbox/Listbox.vue @@ -510,28 +510,28 @@ export default { return this.visibleOptions.findIndex(option => this.isValidOption(option)); }, findLastOptionIndex() { - return this.visibleOptions.findLastIndex(option => this.isValidOption(option)); + return ObjectUtils.findLastIndex(this.visibleOptions, option => this.isValidOption(option)); }, findNextOptionIndex(index) { const matchedOptionIndex = index < (this.visibleOptions.length - 1) ? this.visibleOptions.slice(index + 1).findIndex(option => this.isValidOption(option)) : -1; return matchedOptionIndex > -1 ? matchedOptionIndex + index + 1 : index; }, findPrevOptionIndex(index) { - const matchedOptionIndex = index > 0 ? this.visibleOptions.slice(0, index).findLastIndex(option => this.isValidOption(option)) : -1; + const matchedOptionIndex = index > 0 ? ObjectUtils.findLastIndex(this.visibleOptions.slice(0, index), option => this.isValidOption(option)) : -1; return matchedOptionIndex > -1 ? matchedOptionIndex : index; }, findFirstSelectedOptionIndex() { return this.hasSelectedOption ? this.visibleOptions.findIndex(option => this.isValidSelectedOption(option)) : -1; }, findLastSelectedOptionIndex() { - return this.hasSelectedOption ? this.visibleOptions.findLastIndex(option => this.isValidSelectedOption(option)) : -1; + return this.hasSelectedOption ? ObjectUtils.findLastIndex(this.visibleOptions, option => this.isValidSelectedOption(option)) : -1; }, findNextSelectedOptionIndex(index) { const matchedOptionIndex = this.hasSelectedOption && index < (this.visibleOptions.length - 1) ? this.visibleOptions.slice(index + 1).findIndex(option => this.isValidSelectedOption(option)) : -1; return matchedOptionIndex > -1 ? matchedOptionIndex + index + 1 : -1; }, findPrevSelectedOptionIndex(index) { - const matchedOptionIndex = this.hasSelectedOption && index > 0 ? this.visibleOptions.slice(0, index).findLastIndex(option => this.isValidSelectedOption(option)) : -1; + const matchedOptionIndex = this.hasSelectedOption && index > 0 ? ObjectUtils.findLastIndex(this.visibleOptions.slice(0, index), option => this.isValidSelectedOption(option)) : -1; return matchedOptionIndex > -1 ? matchedOptionIndex : -1; }, findNearestSelectedOptionIndex(index, firstCheckUp = false) { diff --git a/src/components/multiselect/MultiSelect.vue b/src/components/multiselect/MultiSelect.vue index dc77e8a35..e427a4def 100755 --- a/src/components/multiselect/MultiSelect.vue +++ b/src/components/multiselect/MultiSelect.vue @@ -795,28 +795,28 @@ export default { return this.visibleOptions.findIndex(option => this.isValidOption(option)); }, findLastOptionIndex() { - return this.visibleOptions.findLastIndex(option => this.isValidOption(option)); + return ObjectUtils.findLastIndex(this.visibleOptions, option => this.isValidOption(option)); }, findNextOptionIndex(index) { const matchedOptionIndex = index < (this.visibleOptions.length - 1) ? this.visibleOptions.slice(index + 1).findIndex(option => this.isValidOption(option)) : -1; return matchedOptionIndex > -1 ? matchedOptionIndex + index + 1 : index; }, findPrevOptionIndex(index) { - const matchedOptionIndex = index > 0 ? this.visibleOptions.slice(0, index).findLastIndex(option => this.isValidOption(option)) : -1; + const matchedOptionIndex = index > 0 ? ObjectUtils.findLastIndex(this.visibleOptions.slice(0, index), option => this.isValidOption(option)) : -1; return matchedOptionIndex > -1 ? matchedOptionIndex : index; }, findFirstSelectedOptionIndex() { return this.hasSelectedOption ? this.visibleOptions.findIndex(option => this.isValidSelectedOption(option)) : -1; }, findLastSelectedOptionIndex() { - return this.hasSelectedOption ? this.visibleOptions.findLastIndex(option => this.isValidSelectedOption(option)) : -1; + return this.hasSelectedOption ? ObjectUtils.findLastIndex(this.visibleOptions, option => this.isValidSelectedOption(option)) : -1; }, findNextSelectedOptionIndex(index) { const matchedOptionIndex = this.hasSelectedOption && index < (this.visibleOptions.length - 1) ? this.visibleOptions.slice(index + 1).findIndex(option => this.isValidSelectedOption(option)) : -1; return matchedOptionIndex > -1 ? matchedOptionIndex + index + 1 : -1; }, findPrevSelectedOptionIndex(index) { - const matchedOptionIndex = this.hasSelectedOption && index > 0 ? this.visibleOptions.slice(0, index).findLastIndex(option => this.isValidSelectedOption(option)) : -1; + const matchedOptionIndex = this.hasSelectedOption && index > 0 ? ObjectUtils.findLastIndex(this.visibleOptions.slice(0, index), option => this.isValidSelectedOption(option)) : -1; return matchedOptionIndex > -1 ? matchedOptionIndex : -1; }, findNearestSelectedOptionIndex(index, firstCheckUp = false) { diff --git a/src/components/utils/ObjectUtils.js b/src/components/utils/ObjectUtils.js index 04e7c6984..a6c217167 100755 --- a/src/components/utils/ObjectUtils.js +++ b/src/components/utils/ObjectUtils.js @@ -222,5 +222,24 @@ export default { isPrintableCharacter(char = '') { return this.isNotEmpty(char) && char.length === 1 && char.match(/\S| /); + }, + + /** + * Firefox-v103 does not currently support the "findLastIndex" method. It is stated that this method will be supported with Firefox-v104. + * https://caniuse.com/mdn-javascript_builtins_array_findlastindex + */ + findLastIndex(arr, callback) { + let index = -1; + + if (this.isNotEmpty(arr)) { + try { + index = arr.findLastIndex(callback); + } + catch { + index = arr.lastIndexOf([...arr].reverse().find(callback)); + } + } + + return index; } }