From bd068ce2f68fb0c175704544903bb4adc31a7f26 Mon Sep 17 00:00:00 2001 From: xiaomai Date: Fri, 1 May 2026 12:49:08 +0800 Subject: [PATCH] fix(ui): resolve transition key conflicts in reorderable lists Add listKeyPrefix prop to ensure unique keys across list instances Remove enter/leave transition styles to prevent animation glitches --- frontend/src/components/ReorderableList.vue | 8 ++++++- frontend/src/styles/main.css | 24 ++------------------- frontend/src/views/AdminView.vue | 7 ++++++ 3 files changed, 16 insertions(+), 23 deletions(-) diff --git a/frontend/src/components/ReorderableList.vue b/frontend/src/components/ReorderableList.vue index 445f769..8065be4 100644 --- a/frontend/src/components/ReorderableList.vue +++ b/frontend/src/components/ReorderableList.vue @@ -5,10 +5,12 @@ const props = withDefaults(defineProps<{ items: T[]; itemKey: (item: T) => string | number; itemLabel: (item: T) => string; + listKeyPrefix?: string; disabled?: boolean; handleLabel: (name: string) => string; handleTitle: string; }>(), { + listKeyPrefix: '', disabled: false }); @@ -28,6 +30,10 @@ function keyFor(item: T): string | number { return props.itemKey(item); } +function transitionKeyFor(item: T): string { + return props.listKeyPrefix ? `${props.listKeyPrefix}:${String(keyFor(item))}` : String(keyFor(item)); +} + function sameKey(first: string | number, second: string | number): boolean { return String(first) === String(second); } @@ -181,7 +187,7 @@ function handleKeydown(item: T, event: KeyboardEvent) {
  • { :items="configRows" :item-key="configKey" :item-label="configLabel" + :list-key-prefix="`config-${activeConfigType}`" :disabled="busy" :handle-label="dragSortLabel" :handle-title="t('pages.admin.dragSortTitle')" @@ -662,6 +664,7 @@ onMounted(() => { :items="languageRows" :item-key="languageKey" :item-label="languageLabel" + list-key-prefix="languages" :disabled="busy" :handle-label="dragSortLabel" :handle-title="t('pages.admin.dragSortTitle')" @@ -690,6 +693,7 @@ onMounted(() => { :items="pokemonRows" :item-key="pokemonKey" :item-label="pokemonLabel" + list-key-prefix="pokemon" :disabled="busy" :handle-label="dragSortLabel" :handle-title="t('pages.admin.dragSortTitle')" @@ -714,6 +718,7 @@ onMounted(() => { :items="itemRows" :item-key="itemKey" :item-label="itemLabel" + list-key-prefix="items" :disabled="busy" :handle-label="dragSortLabel" :handle-title="t('pages.admin.dragSortTitle')" @@ -738,6 +743,7 @@ onMounted(() => { :items="recipeRows" :item-key="recipeKey" :item-label="recipeLabel" + list-key-prefix="recipes" :disabled="busy" :handle-label="dragSortLabel" :handle-title="t('pages.admin.dragSortTitle')" @@ -762,6 +768,7 @@ onMounted(() => { :items="habitatRows" :item-key="habitatKey" :item-label="habitatLabel" + list-key-prefix="habitats" :disabled="busy" :handle-label="dragSortLabel" :handle-title="t('pages.admin.dragSortTitle')"