fix(editor): dialog trigger for references, Task 11 review minors

This commit is contained in:
bchanot committed 2026-11-15 16:25:32 +01:00
1 parent da755f9768
commit d9dbcf1609
11 files changed
+47 -59

No files matched your search

@@ -7,8 +7,6 @@ import { useT } from '@/i18n/useT'
interface CitationsProps {
item: FindingItem
/** The references dialog is open over the finding dialog (the trigger reads « expanded »). */
citationsOpen: boolean
/** Opens the references dialog of the family or node. */
onShowReferences: (opener: HTMLElement) => void
}
@@ -23,7 +21,6 @@ const RING =
function CitationsTrigger({
item,
count,
citationsOpen,
onShowReferences,
}: CitationsProps & { count: number }) {
const plural = usePlural()
@@ -31,8 +28,7 @@ function CitationsTrigger({
<button
type="button"
data-citations-trigger={JSON.stringify(item.key)}
aria-expanded={citationsOpen}
aria-controls="editor-citations-panel"
aria-haspopup="dialog"
onClick={(event) => onShowReferences(event.currentTarget)}
className={`${PILL} ${RING}`}
>
@@ -65,8 +65,6 @@ function ItemBody(props: ItemBodyProps) {
const { layer } = props
const t = useT()
const mode = useItemMode()
const citationsOpen =
!!layer.view && 'key' in layer.view && layer.view.citations
const showReferences = (opener: HTMLElement) =>
layer.openCitations(props.item.key, opener)
return (
@@ -78,14 +76,12 @@ function ItemBody(props: ItemBodyProps) {
guards={layer.guards}
onDone={mode.done}
onDiscardClose={() => layer.close(true)}
citationsOpen={citationsOpen}
onShowReferences={showReferences}
/>
) : (
<FindingView
item={props.item}
readOnly={props.readOnly}
citationsOpen={citationsOpen}
onEdit={mode.startEdit}
onDelete={() => props.onDelete(props.item)}
onShowReferences={showReferences}
@@ -77,8 +77,6 @@ export interface FindingEditFormProps {
onDone: (saved: boolean) => void
/** « Abandonner » after a close request: the draft goes, so does the dialog. */
onDiscardClose: () => void
/** The references dialog is open over the finding dialog (the trigger reads « expanded »). */
citationsOpen: boolean
/** Opens the references dialog, which lists the element's citations. */
onShowReferences: (opener: HTMLElement) => void
}
@@ -229,7 +227,6 @@ export default function FindingEditForm(props: FindingEditFormProps) {
)}
<CitationsHeader
item={props.item}
citationsOpen={props.citationsOpen}
onShowReferences={props.onShowReferences}
/>
{form.error && (
@@ -9,7 +9,6 @@ import { useT } from '@/i18n/useT'
export interface FindingViewProps {
item: FindingItem
readOnly: boolean
citationsOpen: boolean
onEdit: () => void
onDelete: () => void
onShowReferences: (opener: HTMLElement) => void
@@ -53,7 +52,7 @@ function Texts({ item }: { item: FindingItem }) {
* to its references dialog, and the actions of the edit tier. Nothing here edits a field in place.
*/
export default function FindingView(props: FindingViewProps) {
const { item, readOnly, citationsOpen } = props
const { item, readOnly } = props
const t = useT()
const edit = useEditCommand()
return (
@@ -75,11 +74,7 @@ export default function FindingView(props: FindingViewProps) {
))}
</div>
<Texts item={item} />
<CitationsHeader
item={item}
citationsOpen={citationsOpen}
onShowReferences={props.onShowReferences}
/>
<CitationsHeader item={item} onShowReferences={props.onShowReferences} />
<FindingActions
item={item}
readOnly={readOnly}
@@ -111,8 +111,6 @@ function EntryTile({
movable={false}
on={{
toggle: () => tiles.toggle(key),
// Never offered: a read-only tile has no « Modifier ».
edit: () => undefined,
goTo: (target) => navigate(targetOfKey(target)),
}}
/>
@@ -11,8 +11,11 @@ import type { ReferenceHost } from './referenceTypes'
/** What a tile asks of the library that owns its state. */
export interface TileHandlers {
toggle: () => void
/** « Modifier »: opens the reference dialog; `opener` is where the focus returns. */
edit: (opener: HTMLElement) => void
/**
* « Modifier »: opens the reference dialog; `opener` is where the focus returns. The
* Références tab only: the references dialog's tiles are read only.
*/
edit?: (opener: HTMLElement) => void
/** « Supprimer »: the Références tab only. */
remove?: () => void
/** « Monter » / « Descendre »: the Références tab only. */
@@ -98,27 +101,11 @@ function TileHeader({ base, props }: { base: string; props: TileProps }) {
)
}
/** The panel's one action (P7): « Modifier ». Removing a citation is the edit form's. */
function PanelActions({ props }: { props: TileProps }) {
const t = useT()
return (
<ActionButton
readOnly={false}
variant="secondary"
size="sm"
onClick={(event) => props.on.edit(event.currentTarget)}
>
{t('editor.references.edit')}
</ActionButton>
)
}
/** « Modifier », « Supprimer » (uncited only, else the hint), « Monter » / « Descendre ». */
function TileActions({ props }: { props: TileProps }) {
const t = useT()
const { position, count, citers, readOnly, movable, on } = props
if (readOnly) return null
if (props.panel) return <PanelActions props={props} />
if (readOnly || !on.edit) return null
return (
<>
<div className="flex flex-wrap items-center gap-2">
@@ -126,7 +113,7 @@ function TileActions({ props }: { props: TileProps }) {
readOnly={false}
variant="secondary"
size="sm"
onClick={(event) => on.edit(event.currentTarget)}
onClick={(event) => on.edit?.(event.currentTarget)}
>
{t('editor.references.edit')}
</ActionButton>