fix(app): focus the shown tab after a crossing, one commit per typed field
- A field blurred by a 1 024 px crossing or a read-only switch hands its focus to the shown tab (or Plus), never to body (focusRequest, useViewport). - TextField no longer commits a blurred value twice when it unmounts before the render that brings the new value: one undo step, one count. - Annuler and Retablir share the field left by Tab, so Shift+Tab to Annuler and Enter still skips the undo of a refused field. - Adding a reference clears the finding filter and the search. Unit tests: no-loss (focus on tab and on Plus, one undo entry), history buttons (field kept across the pair), references panel (add clears, refused add keeps).
This commit is contained in:
1 parent
9c03cf2413
commit
0bb150f860
9 files changed
+149
-29
No files matched your search
@@ -10,8 +10,11 @@ import { REFERENCE_TYPES } from './referenceTypes'
|
||||
|
||||
const EMPTY = { type: '', citation: '', url: '', doi: '' }
|
||||
|
||||
/** Adds a reference: the type and the citation are required, URL and DOI optional. */
|
||||
export default function ReferenceForm() {
|
||||
/**
|
||||
* Adds a reference: the type and the citation are required, URL and DOI optional.
|
||||
* `onAdded` runs after a successful add, so the list can show the new reference.
|
||||
*/
|
||||
export default function ReferenceForm({ onAdded }: { onAdded?: () => void }) {
|
||||
const t = useT()
|
||||
const edit = useEditCommand()
|
||||
const [form, setForm] = useState(EMPTY)
|
||||
@@ -41,7 +44,9 @@ export default function ReferenceForm() {
|
||||
},
|
||||
},
|
||||
}))
|
||||
if (added) setForm(EMPTY)
|
||||
if (!added) return
|
||||
setForm(EMPTY)
|
||||
onAdded?.()
|
||||
}
|
||||
return (
|
||||
<div className="space-y-2 rounded-lg border border-dashed border-[var(--color-border)] p-3">
|
||||
|
||||
Reference in new issue
Block a user