From 18a4ed5f6112c014e13f3fd104d2727d14421e83 Mon Sep 17 00:00:00 2001 From: mertsincan Date: Sun, 31 Jul 2022 03:13:02 +0100 Subject: [PATCH] Refactor --- src/components/dropdown/Dropdown.vue | 18 ++---------------- src/components/multiselect/MultiSelect.vue | 18 ++---------------- 2 files changed, 4 insertions(+), 32 deletions(-) diff --git a/src/components/dropdown/Dropdown.vue b/src/components/dropdown/Dropdown.vue index 1b1773ca6..d1d2bfca8 100755 --- a/src/components/dropdown/Dropdown.vue +++ b/src/components/dropdown/Dropdown.vue @@ -462,14 +462,7 @@ export default { }); }, onArrowDownKey(event) { - let optionIndex = -1; - - if (this.focusedOptionIndex !== -1) { - optionIndex = this.findNextOptionIndex(this.focusedOptionIndex); - } - else { - optionIndex = this.findFirstFocusedOptionIndex(); - } + const optionIndex = this.focusedOptionIndex !== -1 ? this.findNextOptionIndex(this.focusedOptionIndex) : this.findFirstFocusedOptionIndex(); this.changeFocusedOptionIndex(event, optionIndex); @@ -486,14 +479,7 @@ export default { event.preventDefault(); } else { - let optionIndex = -1; - - if (this.focusedOptionIndex !== -1) { - optionIndex = this.findPrevOptionIndex(this.focusedOptionIndex); - } - else { - optionIndex = this.findLastFocusedOptionIndex(); - } + const optionIndex = this.focusedOptionIndex !== -1 ? this.findPrevOptionIndex(this.focusedOptionIndex) : this.findLastFocusedOptionIndex(); this.changeFocusedOptionIndex(event, optionIndex); diff --git a/src/components/multiselect/MultiSelect.vue b/src/components/multiselect/MultiSelect.vue index 169203d4f..3d1fde4f8 100755 --- a/src/components/multiselect/MultiSelect.vue +++ b/src/components/multiselect/MultiSelect.vue @@ -534,14 +534,7 @@ export default { } }, onArrowDownKey(event) { - let optionIndex = -1; - - if (this.focusedOptionIndex !== -1) { - optionIndex = this.findNextOptionIndex(this.focusedOptionIndex); - } - else { - optionIndex = this.findFirstFocusedOptionIndex(); - } + const optionIndex = this.focusedOptionIndex !== -1 ? this.findNextOptionIndex(this.focusedOptionIndex) : this.findFirstFocusedOptionIndex(); if (event.shiftKey) { this.onOptionSelectRange(event, this.startRangeIndex, optionIndex); @@ -562,14 +555,7 @@ export default { event.preventDefault(); } else { - let optionIndex = -1; - - if (this.focusedOptionIndex !== -1) { - optionIndex = this.findPrevOptionIndex(this.focusedOptionIndex); - } - else { - optionIndex = this.findLastFocusedOptionIndex(); - } + const optionIndex = this.focusedOptionIndex !== -1 ? this.findPrevOptionIndex(this.focusedOptionIndex) : this.findLastFocusedOptionIndex(); if (event.shiftKey) { this.onOptionSelectRange(event, optionIndex, this.startRangeIndex);