From d47151423161d0715135e37184dcab50b1ef2bd2 Mon Sep 17 00:00:00 2001 From: diondiondion Date: Thu, 11 Sep 2025 16:04:15 +0200 Subject: [PATCH] [Glitch] Update labels in Posting defaults settings Port 872044484c283c914e395828cc1c9b9a0bd0736a to glitch-soc Signed-off-by: Claire --- .../flavours/glitch/entrypoints/public.tsx | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/app/javascript/flavours/glitch/entrypoints/public.tsx b/app/javascript/flavours/glitch/entrypoints/public.tsx index 75c06e7cd0..105b877bc7 100644 --- a/app/javascript/flavours/glitch/entrypoints/public.tsx +++ b/app/javascript/flavours/glitch/entrypoints/public.tsx @@ -351,6 +351,31 @@ const setInputDisabled = ( } }; +const setInputHint = ( + input: HTMLInputElement | HTMLSelectElement, + hintPrefix: string, +) => { + const fieldWrapper = input.closest('.fields-group > .input'); + if (!fieldWrapper) return; + + const hint = fieldWrapper.dataset[`${hintPrefix}Hint`]; + const hintElement = + fieldWrapper.querySelector(':scope > .hint'); + + if (hint) { + if (hintElement) { + hintElement.textContent = hint; + } else { + const newHintElement = document.createElement('span'); + newHintElement.className = 'hint'; + newHintElement.textContent = hint; + fieldWrapper.appendChild(newHintElement); + } + } else { + hintElement?.remove(); + } +}; + Rails.delegate( document, '#account_statuses_cleanup_policy_enabled', @@ -379,6 +404,8 @@ const updateDefaultQuotePrivacyFromPrivacy = ( ); if (!select) return; + setInputHint(select, privacySelect.value); + if (privacySelect.value === 'private') { select.value = 'nobody'; setInputDisabled(select, true);