diff --git a/legalconsenthub/app/components/FormStepperWithNavigation.vue b/legalconsenthub/app/components/FormStepperWithNavigation.vue index 48fabc7..3fe7463 100644 --- a/legalconsenthub/app/components/FormStepperWithNavigation.vue +++ b/legalconsenthub/app/components/FormStepperWithNavigation.vue @@ -264,9 +264,15 @@ onUnmounted(() => { watch( () => activeStepperItemIndex.value, - async () => { + async (newIdx, oldIdx) => { await nextTick() scrollToActiveStep() + + // Emit navigate event when stepper index changes (from direct clicks) + // Note: navigateStepper() emits via its onNavigate callback, so button clicks are covered + if (newIdx !== oldIdx && oldIdx !== undefined) { + emit('navigate', { direction: newIdx > oldIdx ? 'forward' : 'backward', index: newIdx }) + } } ) @@ -379,7 +385,6 @@ function findSubsectionByKey(subsectionKey: string): FormElementSubSectionDto | async function handleNavigate(direction: 'forward' | 'backward') { await navigateStepper(direction) - emit('navigate', { direction, index: activeStepperItemIndex.value }) } function handleCloneElement(element: FormElementDto, position: number, subsectionKey: string) { diff --git a/legalconsenthub/app/pages/application-forms/[id]/[sectionIndex].vue b/legalconsenthub/app/pages/application-forms/[id]/[sectionIndex].vue index 7f37e6b..9477439 100644 --- a/legalconsenthub/app/pages/application-forms/[id]/[sectionIndex].vue +++ b/legalconsenthub/app/pages/application-forms/[id]/[sectionIndex].vue @@ -102,7 +102,8 @@ const isReadOnly = computed(() => { // Unsaved changes tracking const originalFormJson = ref('') -onMounted(() => { +onMounted(async () => { + await nextTick() originalFormJson.value = JSON.stringify(applicationForm.value) window.addEventListener('beforeunload', handleBeforeUnload) }) @@ -161,6 +162,13 @@ watch( { deep: true } ) +// Re-capture baseline after section navigation to absorb initialization effects +// (e.g. TheTable applying row presets, TheEditor normalizing content on mount) +watch(sectionIndex, async () => { + await nextTick() + originalFormJson.value = JSON.stringify(applicationForm.value) +}) + async function onSave() { if (applicationForm.value?.id) { const updated = await updateForm(applicationForm.value.id, applicationForm.value)