Skip to content

Commit ac4d491

Browse files
committed
refactor(vc-blade): simplify aria-label handling and update blade injection
Refactored the aria-label logic for better readability and removed unnecessary initialization for showSkeleton. Updated blade instance and stack injections to use new composables for improved clarity and maintainability.
1 parent 4bcedce commit ac4d491

File tree

1 file changed

+12
-19
lines changed

1 file changed

+12
-19
lines changed

framework/ui/components/organisms/vc-blade/vc-blade.vue

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
]"
1414
:style="{ width: typeof width === 'number' ? `${width}px` : width }"
1515
:aria-labelledby="props.title && !showSkeleton ? bladeTitleId : undefined"
16-
:aria-label="(!props.title || showSkeleton) ? $t('COMPONENTS.VC_BLADE.PANEL') : undefined"
16+
:aria-label="!props.title || showSkeleton ? $t('COMPONENTS.VC_BLADE.PANEL') : undefined"
1717
>
1818
<!-- Header zone: v-show keeps BladeHeader mounted to avoid Teleport unmount bug -->
1919
<template v-if="!($isMobile.value && blades.length === 1 && !$slots['actions'])">
@@ -90,7 +90,7 @@
9090
:items="toolbarItems"
9191
>
9292
<template #widgets-container>
93-
<WidgetContainer :blade-id="blade?.id ?? ''" />
93+
<WidgetContainer :blade-id="bladeId" />
9494
</template>
9595
</BladeToolbar>
9696

@@ -119,19 +119,20 @@
119119
</div>
120120
</template>
121121
<script lang="ts" setup>
122-
import { ref, inject, computed, onMounted, nextTick, getCurrentInstance } from "vue";
122+
import { ref, inject, computed, onMounted, nextTick, watch, getCurrentInstance } from "vue";
123123
import { IBladeToolbar } from "@core/types";
124-
import { BladeStackKey } from "@shared/components/blade-navigation/types";
124+
import { useBladeNavigation, useBladeStack } from "@shared/components/blade-navigation/composables";
125125
import BladeHeader from "@ui/components/organisms/vc-blade/_internal/BladeHeader.vue";
126126
import BladeHeaderSkeleton from "@ui/components/organisms/vc-blade/_internal/BladeHeaderSkeleton.vue";
127127
import BladeToolbar from "@ui/components/organisms/vc-blade/_internal/BladeToolbar.vue";
128128
import BladeToolbarSkeleton from "@ui/components/organisms/vc-blade/_internal/BladeToolbarSkeleton.vue";
129129
import BladeContentSkeleton from "@ui/components/organisms/vc-blade/_internal/BladeContentSkeleton.vue";
130130
import BladeStatusBanners from "@ui/components/organisms/vc-blade/_internal/BladeStatusBanners.vue";
131131
import { VcButton } from "@ui/components/atoms/vc-button";
132-
import { BladeInstance, BLADE_BACK_BUTTON } from "@framework/injection-keys";
132+
import { BladeInstance, BLADE_BACK_BUTTON, BladeBackButtonKey, BladeInstanceKey } from "@framework/injection-keys";
133133
import WidgetContainer from "@ui/components/organisms/vc-blade/_internal/widgets/WidgetContainer.vue";
134134
import { DEFAULT_BLADE_INSTANCE } from "@ui/components/organisms/vc-blade/constants";
135+
import { useBlade } from "../../../../core/composables";
135136
136137
export interface Props {
137138
icon?: string;
@@ -166,16 +167,7 @@ const props = withDefaults(defineProps<Props>(), {
166167
const instanceUid = getCurrentInstance()?.uid ?? 0;
167168
const bladeTitleId = `blade-title-${instanceUid}`;
168169
169-
// Prevent flash of empty content on initial render.
170-
// useAsync starts with loading=false; the action (setting true) runs in onMounted.
171-
// Without this guard, VcBlade renders real (empty) content for 1 frame before skeleton appears.
172-
const isInitializing = ref(props.loading !== undefined);
173-
onMounted(() => {
174-
nextTick(() => {
175-
isInitializing.value = false;
176-
});
177-
});
178-
const showSkeleton = computed(() => Boolean(props.loading) || isInitializing.value);
170+
const showSkeleton = computed(() => Boolean(props.loading));
179171
180172
const slots = defineSlots<{
181173
actions(): void;
@@ -184,12 +176,13 @@ const slots = defineSlots<{
184176
185177
const emit = defineEmits<Emits>();
186178
187-
const blade = inject(BladeInstance, DEFAULT_BLADE_INSTANCE);
179+
const { id: bladeId } = useBlade();
180+
181+
const blade = inject(BladeInstanceKey, DEFAULT_BLADE_INSTANCE);
188182
189-
const backButton = inject(BLADE_BACK_BUTTON);
183+
const backButton = inject(BladeBackButtonKey);
190184
191-
const bladeStack = inject(BladeStackKey);
192-
const blades = computed(() => bladeStack?.blades.value ?? []);
185+
const { blades } = useBladeStack();
193186
194187
const bladeRef = ref<HTMLElement | null>(null);
195188
const contentRef = ref<HTMLElement | null>(null);

0 commit comments

Comments
 (0)