fix inconsistencies in dropdown highlighted item, indirectly fix flaky project member test

This commit is contained in:
Gregor Vostrak
2025-02-13 12:51:28 +01:00
committed by Constantin Graf
parent ae76135373
commit 97585b5771
3 changed files with 16 additions and 21 deletions

View File

@@ -1,6 +1,6 @@
<script setup lang="ts" generic="T">
import Dropdown from '@/packages/ui/src/Input/Dropdown.vue';
import { computed, nextTick, ref, watch } from 'vue';
import {computed, nextTick, onMounted, ref, watch} from 'vue';
import SelectDropdownItem from '@/packages/ui/src/Input/SelectDropdownItem.vue';
import { onKeyStroke } from '@vueuse/core';
import { type Placement } from '@floating-ui/vue';
@@ -43,10 +43,22 @@ const filteredItems = computed<T[]>(() => {
const highlightedItemId = ref<string | null>(model.value);
watch(model, () => {
highlightedItemId.value = model.value;
if(model.value){
highlightedItemId.value = model.value;
}
});
onMounted(() => {
if (!highlightedItemId.value) {
resetHightlightedItem();
}
});
watch(filteredItems, () => {
resetHightlightedItem();
});
function resetHightlightedItem(){
if (
filteredItems.value.length > 0 &&
filteredItems.value.find(
@@ -55,7 +67,7 @@ watch(filteredItems, () => {
) {
highlightedItemId.value = props.getKeyFromItem(filteredItems.value[0]);
}
});
}
watch(highlightedItemId, () => {
if (highlightedItemId.value) {