From 77251fa6362a481663d3603a498af72ff033809d Mon Sep 17 00:00:00 2001 From: bchanot Date: Thu, 19 Nov 2026 15:03:06 +0100 Subject: [PATCH] fix(editor): a held press on another tab leaves the hidden line empty The kept-alive annotations tab showed the reason in its hidden message line, so it came back on the return. A press made while the place is hidden is now only described by the button. --- .../editor/annotations/EditableAnnotations.tsx | 6 ++++-- .../tests/unit/editor-history-buttons.test.tsx | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/apps/app/src/components/editor/annotations/EditableAnnotations.tsx b/apps/app/src/components/editor/annotations/EditableAnnotations.tsx index 4045cef4..04a4f2e3 100644 --- a/apps/app/src/components/editor/annotations/EditableAnnotations.tsx +++ b/apps/app/src/components/editor/annotations/EditableAnnotations.tsx @@ -206,7 +206,8 @@ function resumedOf({ creation, model }: Scene): ZoneTarget | null { /** * A press on a held « Défaire » / « Refaire » (the header's buttons, outside this tree) says - * why on the line under the drawing. A press from before this tab mounted is not replayed. + * why on the line under the drawing. A press from before this tab mounted, or made while + * another tab hides the line, is not replayed: the button's description says it there. */ function useHeldHistoryMessage( message: GestureMessages, @@ -214,10 +215,11 @@ function useHeldHistoryMessage( ) { const press = useAnnotationWork((s) => s.historyPress) const seen = useRef(press) + const visible = usePlaceVisible() useEffect(() => { if (press === seen.current) return seen.current = press - if (press) { + if (press && visible) { message.show(t(`editor.history.hold_${press.reason}`), { undo: false, tone: 'info', diff --git a/apps/app/tests/unit/editor-history-buttons.test.tsx b/apps/app/tests/unit/editor-history-buttons.test.tsx index d4d0efd4..4018d827 100644 --- a/apps/app/tests/unit/editor-history-buttons.test.tsx +++ b/apps/app/tests/unit/editor-history-buttons.test.tsx @@ -767,6 +767,23 @@ describe('why a button is held (point 6)', () => { ) }) + it('on another tab a held « Refaire » keeps its description, and a press does nothing', async () => { + const user = await openAnnotations() + stacks() + await user.click(screen.getByRole('tab', { name: 'Général' })) + pend() + const before = store.getState().documentText + await user.click(redoButton()) + expect(reason(redoButton())).toBe(PENDING) + expect(useAnnotationWork.getState().preview).not.toBeNull() + expect(store.getState().documentText).toBe(before) + expect(store.getState().redo).toHaveLength(1) + noMessage() + // Back on Annotations, the press made elsewhere is not shown in the line. + await user.click(screen.getByRole('tab', { name: 'Annotations' })) + noMessage() + }) + it('give no reason when nothing is pending, nothing to redo or read-only', async () => { const user = await openAnnotations() expect(reason(redoButton())).toBeNull()