feat(app): history reads Défaire / Refaire (R1, D5)

FR names Défaire / Refaire; title = name + shortcut (Ctrl+Z ou ⌘Z /
Ctrl+Maj+Z ou ⇧⌘Z), aria-label = name, aria-keyshortcuts adds Meta forms.
New keys editor.history.{undo,redo}_shortcut (fr, en). FR prose use_parent_body
and repair.body_one/_other say Défaire. Dialog Annuler unchanged.

Assertion map (R-24):
- editor-history-buttons.test.tsx UNDO/REDO constants 'Annuler la dernière
  modification' / 'Rétablir la dernière modification annulée' → 'Défaire la
  dernière modification' / 'Refaire la dernière modification défaite'
- :80-81 title === UNDO/REDO → title `${UNDO} (Ctrl+Z ou ⌘Z)` / `${REDO}
  (Ctrl+Maj+Z ou ⇧⌘Z)`
- :82-83 aria-keyshortcuts 'Control+Z' / 'Control+Shift+Z' → 'Control+Z
  Meta+Z' / 'Control+Shift+Z Meta+Shift+Z'
- visible labels ['Annuler','Rétablir'] → ['Défaire','Refaire']
- tool column absence /Annuler|Rétablir/ → /Défaire|Refaire/ (also
  editor-annotations-tab.test.tsx:514)
- Rétablir button lookup by literal name → REDO constant
- added: EN names unchanged with title '(Ctrl+Z or ⌘Z)'; FR prose contains
  Défaire while use_parent_cancel stays 'Annuler'
- e2e titles/comments only: Annuler/Rétablir → Défaire/Refaire
This commit is contained in:
bchanot committed 2026-11-12 12:39:01 +01:00
1 parent 5803854860
commit 7dda61d2ae
10 files changed
+70 -34

No files matched your search

@@ -149,7 +149,7 @@ test.describe('editor shell journeys (H)', () => {
await selectTab(page, dict, 'general')
const original = await nameField(page).inputValue()
await nameField(page).fill('Saisi, jamais validé')
// « Annuler » is aria-disabled until the typed text is committed: press at its box.
// « Défaire » is aria-disabled until the typed text is committed: press at its box.
await pressAtBox(page, historyButton(page, dict, 'undo'))
await expect(nameField(page)).toHaveValue(original)
await expect(saveLine(page)).not.toHaveText(UNSAVED_LINE)
@@ -157,7 +157,7 @@ test.describe('editor shell journeys (H)', () => {
await expect(nameField(page)).toHaveValue('Saisi, jamais validé')
})
test('a field left empty keeps its error: Tab to « Annuler », Enter, nothing undone, focus back', async ({
test('a field left empty keeps its error: Tab to « Défaire », Enter, nothing undone, focus back', async ({
page,
}) => {
await open(page)
@@ -268,7 +268,7 @@ test.describe('editor shell keyboard order (H)', () => {
await dropLateReplays(context)
})
test('header, tab list, Annuler, Rétablir, then the tools, the canvas and the side column', async ({
test('header, tab list, Défaire, Refaire, then the tools, the canvas and the side column', async ({
page,
}) => {
await open(page)
@@ -290,7 +290,7 @@ test.describe('editor shell keyboard order (H)', () => {
])
})
test('with the panel open: header, tab list, Annuler, Rétablir, the panel, then the page content', async ({
test('with the panel open: header, tab list, Défaire, Refaire, the panel, then the page content', async ({
page,
}) => {
await open(page)
+1 -1
View File
@@ -146,7 +146,7 @@ test.describe('editor shell, kept places (B2a)', () => {
for (const scrolled of [false, true]) {
await page.evaluate((y) => window.scrollTo(0, y), scrolled ? 400 : 0)
for (const target of targets) await target.click({ trial: true })
// « Annuler » / « Rétablir » may be aria-disabled (a trial click would wait).
// « Défaire » / « Refaire » may be aria-disabled (a trial click would wait).
for (const kind of ['undo', 'redo'] as const) {
const button = historyButton(page, dict, kind)
await button.scrollIntoViewIfNeeded()
+1 -1
View File
@@ -437,7 +437,7 @@ export function savedLine(dict: Dict, revision: number): RegExp {
)
}
/** The header « Annuler » / « Rétablir » button (enabled ones take a plain click). */
/** The header « Défaire » / « Refaire » button (enabled ones take a plain click). */
export const historyButton = (page: Page, dict: Dict, kind: 'undo' | 'redo') =>
page.getByRole('button', {
name: dict[`editor.history.${kind}_title`],
@@ -144,7 +144,7 @@ interface EditorTabsProps {
/**
* The draft's tab row (boards 04 and 05): the four tabs from 640 px, Annotations and
* Vérification below it with « Plus » opening a disclosure of the others (no measurement).
* « Annuler » and « Rétablir » sit at the right end of the row on every tab.
* « Défaire » and « Refaire » sit at the right end of the row on every tab.
*/
export default function EditorTabs({
active,
@@ -13,8 +13,8 @@ import EditorGlyph from './EditorGlyph'
type Direction = 'undo' | 'redo'
const SHORTCUT: Record<Direction, string> = {
undo: 'Control+Z',
redo: 'Control+Shift+Z',
undo: 'Control+Z Meta+Z',
redo: 'Control+Shift+Z Meta+Shift+Z',
}
const BUTTON =
@@ -38,7 +38,7 @@ function asField(element: Element | EventTarget | null): HTMLElement | null {
* pointer-down, natural when Tab reaches the button), the click or key then reads the
* store, so the typed text is the last change the undo reverts. A field whose commit was
* refused keeps its error: the step is skipped and focus goes back to it. The field is
* remembered across the pair: from a field, « Annuler » is two Shift+Tab away. A touch
* remembered across the pair: from a field, « Défaire » is two Shift+Tab away. A touch
* press fires pointer leave between its up and its click, so only a mouse leaving the
* button forgets the field (a hovering pointer that left meant no press), or a cancel.
*/
@@ -50,7 +50,7 @@ function usePress(
const forget = () => {
left.current = null
}
// Tab from « Rétablir » to « Annuler » (or back) is still the same press of the pair.
// Tab from « Refaire » to « Défaire » (or back) is still the same press of the pair.
const onBlur = (event: FocusEvent<HTMLElement>) => {
const pair = event.currentTarget.parentElement
if (!pair?.contains(event.relatedTarget as Node | null)) forget()
@@ -104,7 +104,7 @@ function HistoryButton({
<button
type="button"
aria-label={name}
title={name}
title={`${name} (${t(`editor.history.${direction}_shortcut`)})`}
aria-disabled={readOnly || !steppable}
aria-keyshortcuts={SHORTCUT[direction]}
{...press}
@@ -118,7 +118,7 @@ function HistoryButton({
)
}
/** « Annuler » and « Rétablir », at the right of the tab row on every tab. */
/** « Défaire » and « Refaire », at the right of the tab row on every tab. */
export default function HistoryButtons() {
const left = useRef<HTMLElement | null>(null)
return (
+2
View File
@@ -1253,7 +1253,9 @@ export const en: Dict = {
'editor.history.undo': 'Undo',
'editor.history.undo_title': 'Undo the last change',
'editor.history.redo': 'Redo',
'editor.history.undo_shortcut': 'Ctrl+Z or ⌘Z',
'editor.history.redo_title': 'Redo the last undone change',
'editor.history.redo_shortcut': 'Ctrl+Shift+Z or ⇧⌘Z',
'editor.draft.status.saving': 'Saving…',
'editor.draft.status.copy_quota': "Temporary local copy impossible (tab full): not saved on the server",
'editor.draft.status.copy_cap': "Temporary local copy impossible (two other copies in this tab): not saved on the server",
+9 -7
View File
@@ -1281,10 +1281,12 @@ export const fr: Dict = {
'editor.draft.status.unsaved_count_other': '{count} modifications non enregistrées',
'editor.draft.status.saved': 'Enregistré · révision {revision}',
'editor.draft.status.saved_at': 'Enregistré à {time} · révision {revision}',
'editor.history.undo': 'Annuler',
'editor.history.undo_title': 'Annuler la dernière modification',
'editor.history.redo': 'Rétablir',
'editor.history.redo_title': 'Rétablir la dernière modification annulée',
'editor.history.undo': 'Défaire',
'editor.history.undo_title': 'Défaire la dernière modification',
'editor.history.undo_shortcut': 'Ctrl+Z ou ⌘Z',
'editor.history.redo': 'Refaire',
'editor.history.redo_title': 'Refaire la dernière modification défaite',
'editor.history.redo_shortcut': 'Ctrl+Maj+Z ou ⇧⌘Z',
'editor.draft.status.saving': 'Enregistrement…',
'editor.draft.status.copy_quota': "Copie locale temporaire impossible (onglet plein) : non enregistré sur le serveur",
'editor.draft.status.copy_cap': "Copie locale temporaire impossible (deux autres copies dans cet onglet) : non enregistré sur le serveur",
@@ -1441,7 +1443,7 @@ export const fr: Dict = {
'editor.views.drawing.file': "Fichier d'illustration (SVG)",
'editor.views.drawing.use_parent': "Utiliser l'illustration de la vue parente",
'editor.views.drawing.use_parent_title': "Utiliser l'illustration de la vue parente ?",
'editor.views.drawing.use_parent_body': "La vue affichera l'illustration de la vue parente à travers son recadrage. Son propre fichier d'illustration reste enregistré, et vous pouvez annuler ce changement (Annuler). Les annotations de la vue repassent « à confirmer ».",
'editor.views.drawing.use_parent_body': "La vue affichera l'illustration de la vue parente à travers son recadrage. Son propre fichier d'illustration reste enregistré, et vous pouvez défaire ce changement (Défaire). Les annotations de la vue repassent « à confirmer ».",
'editor.views.drawing.use_parent_confirm': "Utiliser l'illustration parente",
'editor.views.drawing.use_parent_cancel': 'Annuler',
'editor.views.pending.cleaning': "Un nettoyage de l'illustration attend votre décision.",
@@ -1470,8 +1472,8 @@ export const fr: Dict = {
'editor.views.frame.kept': "L'illustration reste téléversée ; la vue garde son illustration précédente.",
'editor.views.frame.newly_invalid_repairable': "Ces éléments sortent du nouveau cadre : {names}. Choisissez de nouveau l'illustration pour les réparer en l'attachant.",
'editor.views.repair.title': 'Réparer les annotations hors du nouveau cadre',
'editor.views.repair.body_one': "{count} annotation sort du nouveau cadre de cette illustration. Les valeurs proposées sont calculées dans ce cadre. Rien n'est appliqué avant « Attacher et appliquer » : l'illustration et les nouvelles valeurs sont alors appliquées ensemble, et un seul Annuler les restaure ensemble.",
'editor.views.repair.body_other': "{count} annotations sortent du nouveau cadre de cette illustration. Les valeurs proposées sont calculées dans ce cadre. Rien n'est appliqué avant « Attacher et appliquer » : l'illustration et les nouvelles valeurs sont alors appliquées ensemble, et un seul Annuler les restaure ensemble.",
'editor.views.repair.body_one': "{count} annotation sort du nouveau cadre de cette illustration. Les valeurs proposées sont calculées dans ce cadre. Rien n'est appliqué avant « Attacher et appliquer » : l'illustration et les nouvelles valeurs sont alors appliquées ensemble, et un seul Défaire les restaure ensemble.",
'editor.views.repair.body_other': "{count} annotations sortent du nouveau cadre de cette illustration. Les valeurs proposées sont calculées dans ce cadre. Rien n'est appliqué avant « Attacher et appliquer » : l'illustration et les nouvelles valeurs sont alors appliquées ensemble, et un seul Défaire les restaure ensemble.",
'editor.views.repair.row': '{kind} « {name} »',
'editor.views.repair.path_blocked':
"Ce tracé libre est conservé tel quel. L'illustration ne peut pas être attachée tant qu'il sort du nouveau cadre : l'éditeur ne sait pas encore corriger les points d'un tracé libre.",
@@ -511,7 +511,7 @@ describe('tools and categories', () => {
await mount()
const tools = screen.getByRole('toolbar', { name: 'Outils' })
expect(
within(tools).queryByRole('button', { name: /Annuler|Rétablir/ }),
within(tools).queryByRole('button', { name: /Défaire|Refaire/ }),
).toBeNull()
})
})
@@ -1,4 +1,4 @@
/** Lot E: the header « Annuler » / « Rétablir », the save line's announcements, discard. */
/** Lot E: the header « Défaire » / « Refaire », the save line's announcements, discard. */
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import {
act,
@@ -11,7 +11,9 @@ import {
} from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import DeleteDialog from '@/components/editor/DeleteDialog'
import { en } from '@/i18n/en'
import { fr } from '@/i18n/fr'
import { useLocaleStore } from '@/state/localeStore'
import {
baseText,
commitMove,
@@ -46,8 +48,8 @@ afterEach(() => {
setWidth(1024)
})
const UNDO = 'Annuler la dernière modification'
const REDO = 'Rétablir la dernière modification annulée'
const UNDO = 'Défaire la dernière modification'
const REDO = 'Refaire la dernière modification défaite'
const ready = () =>
screen.findByRole('heading', { level: 1, name: 'Brouillon, version 4' })
const undoButton = () => screen.getByRole('button', { name: UNDO })
@@ -73,17 +75,47 @@ describe('the buttons', () => {
mountDraft()
await ready()
const row = within(screen.getByTestId('history-buttons'))
expect(undoButton()).toHaveAttribute('title', UNDO)
expect(redoButton()).toHaveAttribute('title', REDO)
expect(undoButton()).toHaveAttribute('aria-keyshortcuts', 'Control+Z')
expect(redoButton()).toHaveAttribute('aria-keyshortcuts', 'Control+Shift+Z')
expect(undoButton()).toHaveAttribute('title', `${UNDO} (Ctrl+Z ou ⌘Z)`)
expect(redoButton()).toHaveAttribute('title', `${REDO} (Ctrl+Maj+Z ou ⇧⌘Z)`)
expect(undoButton()).toHaveAttribute(
'aria-keyshortcuts',
'Control+Z Meta+Z',
)
expect(redoButton()).toHaveAttribute(
'aria-keyshortcuts',
'Control+Shift+Z Meta+Shift+Z',
)
expect(row.getAllByRole('button').map((b) => b.textContent)).toEqual([
'Annuler',
'Rétablir',
'Défaire',
'Refaire',
])
expect(undoButton()).not.toHaveAttribute('disabled')
})
it('keep their English names and carry the English shortcut in the title', async () => {
mountDraft()
await ready()
act(() => useLocaleStore.setState({ locale: 'en' }))
const undo = screen.getByRole('button', {
name: en['editor.history.undo_title'],
})
const redo = screen.getByRole('button', {
name: en['editor.history.redo_title'],
})
expect(undo).toHaveAttribute('title', 'Undo the last change (Ctrl+Z or ⌘Z)')
expect(redo).toHaveAttribute(
'title',
'Redo the last undone change (Ctrl+Shift+Z or ⇧⌘Z)',
)
})
it('French prose says « Défaire » while the dialog cancel stays « Annuler »', () => {
expect(fr['editor.views.drawing.use_parent_body']).toContain('(Défaire)')
expect(fr['editor.views.repair.body_one']).toContain('un seul Défaire')
expect(fr['editor.views.repair.body_other']).toContain('un seul Défaire')
expect(fr['editor.views.drawing.use_parent_cancel']).toBe('Annuler')
})
it('are enabled exactly when the store can step, and step', async () => {
const user = userEvent.setup()
mountDraft()
@@ -202,7 +234,7 @@ describe('the buttons', () => {
name: fr['editor.annotations.tools'],
})
expect(
within(tools).queryByRole('button', { name: /Annuler|Rétablir/ }),
within(tools).queryByRole('button', { name: /Défaire|Refaire/ }),
).toBeNull()
})
})
@@ -315,7 +347,7 @@ describe('typed text and the press', () => {
expect(store.getState().undo).toHaveLength(1)
})
it('a field left through « Rétablir » to « Annuler » still skips the undo', async () => {
it('a field left through « Refaire » to « Défaire » still skips the undo', async () => {
const user = userEvent.setup()
mountDraft()
await ready()
@@ -324,7 +356,7 @@ describe('typed text and the press', () => {
await user.clear(field)
field.blur()
const redo = screen.getByRole('button', {
name: 'Rétablir la dernière modification annulée',
name: REDO,
})
act(() => redo.focus())
fireEvent.focus(redo, { relatedTarget: field })
@@ -489,7 +521,7 @@ describe('« Abandonner les modifications »', () => {
).toBeInTheDocument()
})
it('keeps the session\'s save in the save line, and the save line says it', async () => {
it("keeps the session's save in the save line, and the save line says it", async () => {
const user = userEvent.setup()
sb.saveSheetDraft.mockResolvedValue({ revision: 4 } as never)
sb.getOfficialSheetAdmin.mockRejectedValue(new Error('offline'))