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.
This commit is contained in:
bchanot committed 2026-11-19 15:03:06 +01:00
1 parent 531bbef619
commit 77251fa636
2 files changed
+21 -2

No files matched your search

@@ -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',
@@ -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()