Skip to content

Commit 47ca03a

Browse files
committed
fix(signature-footer): save concrete template value instead of empty sentinel
Previously onTemplateReset and onCustomizeFooterTemplateChange used footerTemplate:'' as a sentinel meaning 'use the inherited template'. This sentinel relied on the value-computed hook to inject inheritedTemplate at display time, but the emitted model value carried '' — which gets saved to the user preference as-is. On the next page load, if inheritedTemplate resolved to something different (or to '' because no admin customization exists), the display and the preference diverged, showing blank or the wrong value after reset. Fix: make both operations save the concrete value: - onTemplateReset now saves footerTemplate:props.inheritedTemplate so the preference stores the real inherited default explicitly. - onCustomizeFooterTemplateChange (enable path) now seeds the template with the current display value (which already incorporates inheritedTemplate via the computed) so enabling customization never stores an empty template when an inherited default is available. Signed-off-by: Vitor Mattos <[email protected]>
1 parent 30cb40a commit 47ca03a

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

src/views/Settings/PolicyWorkbench/settings/signature-footer/SignatureFooterRuleEditor.vue

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,10 @@ const showResetTemplateButton = computed(() => {
213213
}
214214
215215
const inheritedTemplate = (props.inheritedTemplate ?? '').trim()
216+
if (inheritedTemplate.length === 0) {
217+
return true
218+
}
219+
216220
return currentTemplate !== inheritedTemplate
217221
})
218222
@@ -267,7 +271,10 @@ function onCustomizeFooterTemplateChange(customizeFooterTemplate: boolean) {
267271
return
268272
}
269273
270-
updateValue({ customizeFooterTemplate })
274+
// When enabling customization, seed the template with the inherited default so the
275+
// saved value is concrete and not dependent on future inherited-template resolution.
276+
const seedTemplate = value.value.footerTemplate || (props.inheritedTemplate ?? '')
277+
updateValue({ customizeFooterTemplate, footerTemplate: seedTemplate })
271278
}
272279
273280
function onFooterTemplateChange(footerTemplate: string | number) {
@@ -283,9 +290,12 @@ function onTemplateReset(event?: Event) {
283290
event?.stopPropagation()
284291
event?.preventDefault()
285292
293+
// Reset to the concrete inherited template so the saved value is explicit and
294+
// independent of future inherited-template resolution. Using '' (empty) as a
295+
// sentinel would break when the inheritedTemplate changes between page loads.
286296
updateValue({
287297
customizeFooterTemplate: true,
288-
footerTemplate: '',
298+
footerTemplate: props.inheritedTemplate ?? '',
289299
})
290300
onTemplateChanged()
291301
}

0 commit comments

Comments
 (0)