fix(editor): « Défaire » cancels pending work; reasons only when they help

A press on « Défaire » over a pending series or mode keeps the focus and
skips the field commit, so its handle's blur no longer commits before
the cancel (R-13): the redo stack survives. A held button gives its
reason only when that cause alone holds it; redo during a creation gets
its own text, and the pending text says to cancel with « Défaire ».
This commit is contained in:
bchanot committed 2026-11-19 14:52:51 +01:00
1 parent de418b29a9
commit 59e189c375
6 files changed
+184 -40

No files matched your search

+31 -3
View File
@@ -228,7 +228,18 @@ test.describe('editor annotations (A3)', () => {
}) => {
const { actor } = await openAnnotations(page)
requests.forbid(actor.account.email, actor.account.password)
const reason = dict['editor.history.hold_creation']
const reason = dict['editor.history.hold_creation_redo']
// Something to undo and to redo: a reason shows only when the creation alone holds.
for (const [name, x] of [
['Point un', 300],
['Point deux', 400],
] as const) {
await tool(page, 'point').click()
await clickDrawing(page, x, 300)
await fillCreation(page, { fr: name, en: name })
await createFromPanel(page)
}
await historyButton(page, dict, 'undo').click()
// A zone tracing is a creation with no modal dialog: the header stays reachable.
await tool(page, 'zone').click()
await clickDrawing(page, 600, 200)
@@ -237,7 +248,7 @@ test.describe('editor annotations (A3)', () => {
await expect(redo).toHaveAttribute('aria-disabled', 'true')
await expect(redo).toHaveAccessibleDescription(reason)
await expect(historyButton(page, dict, 'undo')).toHaveAccessibleDescription(
reason,
dict['editor.history.hold_creation'],
)
await expectAccessible(page, 'a held « Refaire » during a creation')
await expectNoShift(page, async () => {
@@ -247,7 +258,7 @@ test.describe('editor annotations (A3)', () => {
await expect(page.getByTestId('gesture-message')).toHaveCount(1)
})
test('a mouse click on « Refaire » during an arrow series says why and keeps the focus', async ({
test('a mouse click on « Refaire » during an arrow series says why; « Défaire » cancels and keeps the redo', async ({
page,
requests,
}) => {
@@ -261,9 +272,20 @@ test.describe('editor annotations (A3)', () => {
name: 'Point Point un',
exact: true,
})
const placed = await shownNumber(page, 'cx')
// A move to redo: one arrow committed by Enter, then undone.
await handle.focus()
await page.keyboard.press('ArrowRight')
await page.keyboard.press('Enter')
const moved = await shownNumber(page, 'cx')
const undo = historyButton(page, dict, 'undo')
const redo = historyButton(page, dict, 'redo')
await undo.click()
await expect(shownShape(page)).toHaveAttribute('cx', String(placed))
// Two arrows pending: a commit then an undo would leave them, not the move, to redo.
await handle.focus()
await page.keyboard.press('ArrowRight')
await page.keyboard.press('ArrowRight')
await expect(redo).toHaveAccessibleDescription(
dict['editor.history.hold_pending'],
)
@@ -278,6 +300,12 @@ test.describe('editor annotations (A3)', () => {
await expect(redo).toHaveAccessibleDescription(
dict['editor.history.hold_pending'],
)
// The reason's advice holds: « Défaire » cancels the series, the redo is still there.
await pressAtBox(page, undo)
await expect(shownShape(page)).toHaveAttribute('cx', String(placed))
await expect(redo).toHaveAttribute('aria-disabled', 'false')
await redo.click()
await expect(shownShape(page)).toHaveAttribute('cx', String(moved))
})
test('a click with jitter never moves; a drag moves by the pointer delta', async ({