mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-17 12:42:15 +01:00
fix inconsistencies in dropdown highlighted item, indirectly fix flaky project member test
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, onMounted, ref, watch } from 'vue';
|
import { computed, ref } from 'vue';
|
||||||
import { storeToRefs } from 'pinia';
|
import { storeToRefs } from 'pinia';
|
||||||
import { useMembersStore } from '@/utils/useMembers';
|
import { useMembersStore } from '@/utils/useMembers';
|
||||||
import { UserIcon, ChevronDownIcon } from '@heroicons/vue/24/solid';
|
import { UserIcon, ChevronDownIcon } from '@heroicons/vue/24/solid';
|
||||||
@@ -46,22 +46,6 @@ const filteredMembers = computed<Member[]>(() => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
watch(filteredMembers, () => {
|
|
||||||
resetHighlightedItem();
|
|
||||||
});
|
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
resetHighlightedItem();
|
|
||||||
});
|
|
||||||
|
|
||||||
function resetHighlightedItem() {
|
|
||||||
if (filteredMembers.value.length > 0) {
|
|
||||||
highlightedItemId.value = filteredMembers.value[0].id;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const highlightedItemId = ref<string | null>(null);
|
|
||||||
|
|
||||||
const currentValue = computed(() => {
|
const currentValue = computed(() => {
|
||||||
if (model.value) {
|
if (model.value) {
|
||||||
return members.value.find((member) => member.id === model.value)?.name;
|
return members.value.find((member) => member.id === model.value)?.name;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<script setup lang="ts" generic="T">
|
<script setup lang="ts" generic="T">
|
||||||
import Dropdown from '@/packages/ui/src/Input/Dropdown.vue';
|
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 SelectDropdownItem from '@/packages/ui/src/Input/SelectDropdownItem.vue';
|
||||||
import { onKeyStroke } from '@vueuse/core';
|
import { onKeyStroke } from '@vueuse/core';
|
||||||
import { type Placement } from '@floating-ui/vue';
|
import { type Placement } from '@floating-ui/vue';
|
||||||
@@ -43,10 +43,22 @@ const filteredItems = computed<T[]>(() => {
|
|||||||
const highlightedItemId = ref<string | null>(model.value);
|
const highlightedItemId = ref<string | null>(model.value);
|
||||||
|
|
||||||
watch(model, () => {
|
watch(model, () => {
|
||||||
highlightedItemId.value = model.value;
|
if(model.value){
|
||||||
|
highlightedItemId.value = model.value;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
if (!highlightedItemId.value) {
|
||||||
|
resetHightlightedItem();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
watch(filteredItems, () => {
|
watch(filteredItems, () => {
|
||||||
|
resetHightlightedItem();
|
||||||
|
});
|
||||||
|
|
||||||
|
function resetHightlightedItem(){
|
||||||
if (
|
if (
|
||||||
filteredItems.value.length > 0 &&
|
filteredItems.value.length > 0 &&
|
||||||
filteredItems.value.find(
|
filteredItems.value.find(
|
||||||
@@ -55,7 +67,7 @@ watch(filteredItems, () => {
|
|||||||
) {
|
) {
|
||||||
highlightedItemId.value = props.getKeyFromItem(filteredItems.value[0]);
|
highlightedItemId.value = props.getKeyFromItem(filteredItems.value[0]);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
watch(highlightedItemId, () => {
|
watch(highlightedItemId, () => {
|
||||||
if (highlightedItemId.value) {
|
if (highlightedItemId.value) {
|
||||||
|
|||||||
@@ -175,7 +175,6 @@ type BillableOption = {
|
|||||||
size="xlarge">
|
size="xlarge">
|
||||||
<TagIcon
|
<TagIcon
|
||||||
v-if="timeEntry.tags.length === 0"
|
v-if="timeEntry.tags.length === 0"
|
||||||
tag="button"
|
|
||||||
class="w-4"></TagIcon>
|
class="w-4"></TagIcon>
|
||||||
<div
|
<div
|
||||||
v-else
|
v-else
|
||||||
|
|||||||
Reference in New Issue
Block a user