fix(editor): Task 7 round 1, reveal reset, forced-colors ring

This commit is contained in:
bchanot committed 2026-11-14 14:28:20 +01:00
1 parent 085c56877c
commit 4018344ffc
5 files changed
+37 -5

No files matched your search

@@ -42,7 +42,7 @@ interface Props extends EditorPlaceProps {
/** A panel takes the focus after « Plus »: the ring shows for the keyboard only. */
const PANEL_FOCUS =
'focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-accent)]'
'focus:outline-none focus-visible:outline-2 focus-visible:outline-transparent focus-visible:ring-2 focus-visible:ring-[var(--color-accent)]'
function TabPanel({
id,
@@ -140,7 +140,10 @@ function useRestoredView(owner: HistoryOwner) {
return view
}
/** A step that brought a finding back shows Constats, where its row is revealed. */
/**
* A step that brought a finding back shows Constats, where its row is revealed. The tab
* move is a history entry on purpose: Back returns to where the user was.
*/
function useShowRestored(nav: EditorNavigation) {
const revealed = useEditorStore((s) => s.revealed)
const { tab } = nav.state
@@ -63,8 +63,8 @@ function useFindingDeletion(
setAsk({ target, fallback: fallbackAfterRemoval(items, item) })
}
// The element is gone: its dialog closes in the same move, by the pop of its entry (a
// Back step that was taken, never a dead one left behind) and the focus lands on the nearest row once every dialog is closed, unless a newer
// landing supersedes it.
// Back step that was taken, never a dead one left behind). The focus lands on the
// nearest row once every dialog is closed, unless a newer landing supersedes it.
const closeDelete = () => {
setAsk(null)
if (!ask || currentItems().some((item) => item.id === selectedId)) return
+1 -1
View File
@@ -83,7 +83,7 @@ export function stepHistory(
if (!replaced.ok) return replaced
const patch = replacedPatch(state, step.text, replaced.state, step.history)
const key = appearedFinding(state.documentText, step.text)
api.set(key ? { ...patch, revealed: { key } } : patch)
api.set({ ...patch, revealed: key ? { key } : null })
return { ok: true }
}
@@ -195,6 +195,35 @@ describe('deleting (owner item 3)', () => {
await waitFor(() => expect(row).toHaveFocus())
})
it('a later step that brings no finding back refocuses nothing', async () => {
const user = await mount()
const zone = { kind: 'zone', id: 'zone-a' }
const element = {
kind: 'zone',
value: {
id: 'zone-a',
name: name('Zone B'),
categories: doc().finding_zones[0].categories,
},
}
act(() => {
store.getState().commit({ op: 'update', key: zone, element } as never)
})
await openFinding(user, /Node A/)
await deleteOpen(user)
const undo = () =>
user.click(screen.getByRole('button', { name: /^Défaire/ }))
await undo()
const row = await screen.findByRole('treeitem', { name: /Node A/ })
await waitFor(() => expect(row).toHaveFocus())
expect(store.getState().revealed).toBeNull()
act(() => row.blur())
await undo()
await screen.findByRole('treeitem', { name: /Zone A/ })
expect(store.getState().revealed).toBeNull()
expect(row).not.toHaveFocus()
})
it('« Refaire » of a creation shows its row the same way', async () => {
const user = await mount()
await openFinding(user, /Node A/)