Skip to content

Commit e1e8920

Browse files
committed
fix(signature-footer): fall back to system default when inherited template is empty
When all admin-level customizations are deleted, the policy's inheritedValue has an empty footerTemplate. Previously resolveEditorProps unconditionally overrode baseEditorProps.inheritedTemplate with that empty string, silently discarding the system-level default injected by PHP via loadState('libresign', 'footer_template', ''). Now resolveEditorProps only overrides inheritedTemplate when the inherited level provides a non-empty custom footer template. Otherwise it falls back to baseEditorProps.inheritedTemplate, preserving the real system default so the user reset button always restores a meaningful value instead of blank. Signed-off-by: Vitor Mattos <[email protected]>
1 parent 8090aed commit e1e8920

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

src/views/Settings/PolicyWorkbench/settings/signature-footer/realDefinition.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,17 @@ export const signatureFooterRealDefinition: RealPolicySettingDefinition = {
2727
},
2828
resolveEditorProps: (policy: EffectivePolicyState | null, baseEditorProps: Record<string, unknown>) => {
2929
const policyWithInherited = policy as (EffectivePolicyState & { inheritedValue?: EffectivePolicyValue }) | null
30-
const normalizedInherited = normalizeSignatureFooterPolicyConfig(policyWithInherited?.inheritedValue ?? null)
31-
if (normalizedInherited.footerTemplate) {
30+
if (policyWithInherited && Object.prototype.hasOwnProperty.call(policyWithInherited, 'inheritedValue')) {
31+
const normalizedInherited = normalizeSignatureFooterPolicyConfig(policyWithInherited.inheritedValue ?? null)
32+
// Only override the base inheritedTemplate when the inherited policy level provides a non-empty
33+
// custom footer template. Otherwise fall back to the base (which carries the system-level
34+
// footer_template from loadState) so the user always sees the real default instead of blank.
35+
const resolvedTemplate = normalizedInherited.footerTemplate.trim() !== ''
36+
? normalizedInherited.footerTemplate
37+
: (baseEditorProps.inheritedTemplate as string | undefined) ?? ''
3238
return {
3339
...baseEditorProps,
34-
inheritedTemplate: normalizedInherited.footerTemplate,
40+
inheritedTemplate: resolvedTemplate,
3541
}
3642
}
3743

0 commit comments

Comments
 (0)