From 1a0ddaada5d3aab4728b41ebebd2bea10b7890d9 Mon Sep 17 00:00:00 2001 From: Scott Nonnenberg Date: Wed, 25 Feb 2026 08:13:23 +1000 Subject: [PATCH] GroupMemberLabelEditor: After save, ensure `dirty = false` before navigate --- .../GroupMemberLabelEditor.dom.tsx | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/ts/components/conversation/conversation-details/GroupMemberLabelEditor.dom.tsx b/ts/components/conversation/conversation-details/GroupMemberLabelEditor.dom.tsx index a64e162231..7ceab345c2 100644 --- a/ts/components/conversation/conversation-details/GroupMemberLabelEditor.dom.tsx +++ b/ts/components/conversation/conversation-details/GroupMemberLabelEditor.dom.tsx @@ -42,6 +42,7 @@ import type { import type { LocalizerType, ThemeType } from '../../../types/Util.std.js'; import type { PreferredBadgeSelectorType } from '../../../state/selectors/badges.preload.js'; import type { Location } from '../../../types/Nav.std.js'; +import { usePrevious } from '../../../hooks/usePrevious.std.js'; export type PropsDataType = { existingLabelEmoji: string | undefined; @@ -119,8 +120,8 @@ export function GroupMemberLabelEditor({ const labelStringForSave = labelString ? labelString.trim() : labelString; const isDirty = - labelEmoji !== existingLabelEmoji || - labelStringForSave !== existingLabelString; + (labelEmoji || undefined) !== (existingLabelEmoji || undefined) || + (labelStringForSave || undefined) !== (existingLabelString || undefined); const canSave = isDirty && ((!labelEmoji && !labelStringForSave) || labelStringForSave); const spinner = isSaving @@ -157,6 +158,15 @@ export function GroupMemberLabelEditor({ }, [confirmDiscardIf, isDirty]); tryClose.current = onTryClose; + // Popping the panel here after a save is far safer; we may not have re-rendered with + // the new existing values yet when the onSuccess callback down-file is called. + const previousIsSaving = usePrevious(isSaving, isSaving); + useEffect(() => { + if (isSaving === false && previousIsSaving !== isSaving && !isDirty) { + popPanelForConversation(); + } + }, [isDirty, isSaving, popPanelForConversation, previousIsSaving]); + return (
@@ -385,7 +395,6 @@ export function GroupMemberLabelEditor({ { onSuccess() { setIsSaving(false); - popPanelForConversation(); }, onFailure() { setIsSaving(false);