diff --git a/apps/app/e2e/shell/editor-references.spec.ts b/apps/app/e2e/shell/editor-references.spec.ts
index a3f15495..cf0f6657 100644
--- a/apps/app/e2e/shell/editor-references.spec.ts
+++ b/apps/app/e2e/shell/editor-references.spec.ts
@@ -486,6 +486,41 @@ test.describe('reference tiles, search, sort and add', () => {
).toBeVisible()
})
+ test('a tile edited out of the search stays after « Terminer », with its line, until the next search', async ({
+ page,
+ requests,
+ }) => {
+ test.setTimeout(150_000)
+ const { actor } = await open(page, sortShape)
+ requests.forbid(actor.account.email, actor.account.password)
+ await openTab(page, dict, 'references')
+ const bar = toolbar(page)
+ const notice = libraryRoot(page).getByTestId('editor-references-no-result')
+ await bar.search.fill('alpha')
+ await expect(headers(page)).toHaveCount(1)
+ await headers(page).first().click()
+ const tile = tileAt(page, 0)
+ await tile
+ .getByRole('button', { name: dict['editor.references.edit'] })
+ .click()
+ const citation = tile.getByLabel(dict['editor.reference.citation'])
+ await citation.fill('Autre titre')
+ await tile
+ .getByRole('button', {
+ name: dict['editor.references.done'],
+ exact: true,
+ })
+ .click()
+ await expect(
+ tile.getByText(dict['editor.references.outside_search']),
+ ).toBeVisible()
+ await expect(notice).toHaveCount(0)
+ await expect(bar.clear).toBeVisible()
+ await bar.search.fill('alphab')
+ await expect(notice).toBeVisible()
+ await expect(headers(page)).toHaveCount(0)
+ })
+
test('a refused draft is never dropped silently by a read-only flip', async ({
page,
}) => {
diff --git a/apps/app/src/components/editor/references/ReferenceTile.tsx b/apps/app/src/components/editor/references/ReferenceTile.tsx
index f105875c..b8ca3367 100644
--- a/apps/app/src/components/editor/references/ReferenceTile.tsx
+++ b/apps/app/src/components/editor/references/ReferenceTile.tsx
@@ -48,6 +48,8 @@ export interface TileProps {
readOnly: boolean
/** ↑ / ↓ only while neither the search nor a sort narrows or reorders the list. */
movable: boolean
+ /** The tab's pinned tile the current search misses: it says so under its header. */
+ outsideSearch?: boolean
on: TileHandlers
}
@@ -93,6 +95,7 @@ function TileHeader({
data-tile-header
aria-expanded={open || editing}
aria-controls={`${base}-body`}
+ aria-describedby={props.outsideSearch ? `${base}-outside` : undefined}
onClick={onToggle}
className={`grid min-h-11 w-full grid-cols-[1.25rem_1fr] items-start gap-x-3 gap-y-1 rounded-lg p-3 text-left ${META_COLUMN[props.host]} ${BUTTON_RING}`}
>
@@ -296,6 +299,14 @@ export default function ReferenceTile(props: TileProps) {
headerRef={headerRef}
onToggle={toggle}
/>
+ {props.outsideSearch && (
+
+ {t('editor.references.outside_search')}
+
+ )}
{(open || editing) && (
tiles: ReturnType
+ /** The current search: a tile it misses (a pinned one) says so. */
+ query: string
readOnly: boolean
movable: boolean
navigate: (target: EditorTarget) => void
@@ -49,6 +52,7 @@ export default function ReferenceTiles(props: Props) {
editing={!props.readOnly && tiles.editingKey === key}
readOnly={props.readOnly}
movable={props.movable}
+ outsideSearch={!referenceMatches(reference, props.query)}
on={{
toggle: () => tiles.toggle(key, props.readOnly),
edit: () => props.onEdit(position),
diff --git a/apps/app/src/components/editor/tabs/ReferencesTab.tsx b/apps/app/src/components/editor/tabs/ReferencesTab.tsx
index d1a90654..cc7890a1 100644
--- a/apps/app/src/components/editor/tabs/ReferencesTab.tsx
+++ b/apps/app/src/components/editor/tabs/ReferencesTab.tsx
@@ -59,7 +59,7 @@ function Library({ readOnly, navigate, focus, resetSignal }: Props) {
{lib.loaded && (
<>
{all.length === 0 && }
- {all.length > 0 && shown.matchCount === 0 && (
+ {all.length > 0 && shown.positions.length === 0 && (
)}
{!readOnly && !sheetView && shown.positions.length > 0 && (
@@ -73,6 +73,7 @@ function Library({ readOnly, navigate, focus, resetSignal }: Props) {
keys={lib.keys}
citers={lib.citers}
tiles={lib.tiles}
+ query={shown.view.query}
readOnly={readOnly}
movable={sheetView}
navigate={navigate}
diff --git a/apps/app/src/i18n/en.ts b/apps/app/src/i18n/en.ts
index 94688a7d..57360cfe 100644
--- a/apps/app/src/i18n/en.ts
+++ b/apps/app/src/i18n/en.ts
@@ -1271,6 +1271,7 @@ export const en: Dict = {
'editor.references.reorder_hint': 'To reorder, show the sheet order without a search.',
'editor.references.no_result': 'No reference contains “{q}”.',
'editor.references.no_result_scope': 'The search covers the citation, the DOI and the URL.',
+ 'editor.references.outside_search': 'Does not match the search',
'editor.findings.references_open_one': '{count} reference',
'editor.findings.references_open_other': '{count} references',
'editor.draft.loading': 'Loading the draft…',
diff --git a/apps/app/src/i18n/fr.ts b/apps/app/src/i18n/fr.ts
index ee8825cb..9fd4cb67 100644
--- a/apps/app/src/i18n/fr.ts
+++ b/apps/app/src/i18n/fr.ts
@@ -1302,6 +1302,7 @@ export const fr: Dict = {
'editor.references.reorder_hint': 'Pour réorganiser, affichez l\'ordre de la fiche sans recherche.',
'editor.references.no_result': 'Aucune référence ne contient « {q} ».',
'editor.references.no_result_scope': 'La recherche porte sur la citation, le DOI et l\'URL.',
+ 'editor.references.outside_search': 'Ne correspond pas à la recherche',
'editor.findings.references_open_one': '{count} référence',
'editor.findings.references_open_other': '{count} références',
'editor.draft.loading': 'Chargement du brouillon…',
diff --git a/apps/app/tests/unit/editor-references-flip.test.tsx b/apps/app/tests/unit/editor-references-flip.test.tsx
index fc805cb6..4298c861 100644
--- a/apps/app/tests/unit/editor-references-flip.test.tsx
+++ b/apps/app/tests/unit/editor-references-flip.test.tsx
@@ -23,7 +23,10 @@ vi.mock('@faunosteo/supabase', async (orig) => ({
}))
beforeEach(() => useLocaleStore.setState({ locale: 'fr' }))
+/** Every watcher made by `watchNotes`: stopped after each test, even a failing one. */
+const watchers: { stop: () => void }[] = []
afterEach(() => {
+ watchers.splice(0).forEach((watch) => watch.stop())
cleanup()
resetStore()
setWidth(1024)
@@ -131,7 +134,9 @@ function watchNotes() {
}
wrap(live(), 'textContent')
wrap(document.createTextNode(''), 'nodeValue')
- return { seen, stop: () => restore.forEach((undo) => undo()) }
+ const watch = { seen, stop: () => restore.forEach((undo) => undo()) }
+ watchers.push(watch)
+ return watch
}
async function mount(width = 1280) {
diff --git a/apps/app/tests/unit/editor-references-view.test.tsx b/apps/app/tests/unit/editor-references-view.test.tsx
index cceeec05..3e769d96 100644
--- a/apps/app/tests/unit/editor-references-view.test.tsx
+++ b/apps/app/tests/unit/editor-references-view.test.tsx
@@ -396,6 +396,93 @@ describe('the tile in edit is pinned (P23)', () => {
})
})
+describe('the tile outside the search (C3)', () => {
+ const line = 'Ne correspond pas à la recherche'
+ const notice = () => screen.queryByTestId('editor-references-no-result')
+ const lineOf = (id: string) =>
+ within(header(id).closest('li')!).queryByText(line)
+
+ async function editedOut(user: User) {
+ await user.type(search(), 'zèbre')
+ const item = await startEdit(user, 'r1')
+ const citation = within(item).getByLabelText('Citation')
+ await user.clear(citation)
+ await user.type(citation, 'Autre titre')
+ return item
+ }
+
+ it('after « Terminer » shows the tile with its line, no notice, focus on its header', async () => {
+ const { user } = await mount()
+ await user.clear(search())
+ await user.type(search(), 'alpha')
+ const item = await startEdit(user, 'r5')
+ await user.clear(within(item).getByLabelText('Citation'))
+ await user.type(within(item).getByLabelText('Citation'), 'Autre titre')
+ await user.click(within(item).getByRole('button', { name: 'Terminer' }))
+ expect(order()).toEqual(['r5'])
+ expect(lineOf('r5')).toBeVisible()
+ expect(notice()).toBeNull()
+ expect(screen.getByText('0 référence sur 5')).toBeInTheDocument()
+ expect(document.activeElement).toBe(header('r5'))
+ expect(header('r5').getAttribute('aria-describedby')).toBe(lineOf('r5')!.id)
+ expect(header('r5')).toHaveAccessibleDescription(line)
+ expect(
+ screen.getByRole('button', { name: 'Effacer la recherche' }),
+ ).toBeVisible()
+ })
+
+ it('the next search change drops the tile and shows the notice', async () => {
+ const { user } = await mount()
+ await user.type(search(), 'alpha')
+ const item = await startEdit(user, 'r5')
+ await user.clear(within(item).getByLabelText('Citation'))
+ await user.type(within(item).getByLabelText('Citation'), 'Autre titre')
+ await user.click(within(item).getByRole('button', { name: 'Terminer' }))
+ await user.type(search(), 'x')
+ expect(order()).toEqual([])
+ expect(notice()).not.toBeNull()
+ })
+
+ it('a tile in edit that does not match carries the line', async () => {
+ const { user } = await mount()
+ const item = await editedOut(user)
+ expect(lineOf('r1')).toBeNull()
+ await user.type(search(), 'x')
+ expect(within(item).getByLabelText('Citation')).toBeVisible()
+ expect(lineOf('r1')).toBeVisible()
+ })
+
+ it('a matching pinned tile has no line', async () => {
+ const { user } = await mount()
+ await startEdit(user, 'r1')
+ await user.type(search(), 'alpha')
+ expect(lineOf('r1')).toBeVisible()
+ expect(lineOf('r5')).toBeNull()
+ await user.clear(search())
+ expect(lineOf('r1')).toBeNull()
+ })
+
+ it('a read-only flip keeps the tile and its line', async () => {
+ const { user, view } = await mount()
+ await startEdit(user, 'r1')
+ await user.type(search(), 'alpha')
+ view.rerender(lib(true))
+ expect(order()).toEqual(['r1', 'r5'])
+ expect(lineOf('r1')).toBeVisible()
+ expect(notice()).toBeNull()
+ })
+
+ it('an open draft tile does not hide the notice for a search matching nothing', async () => {
+ const { user } = await mount()
+ await user.click(
+ screen.getByRole('button', { name: 'Ajouter une référence' }),
+ )
+ await user.type(search(), 'radiographie')
+ expect(order()).toEqual([])
+ expect(notice()).not.toBeNull()
+ })
+})
+
describe('adding (P24)', () => {
const add = () =>
screen.getByRole('button', { name: 'Ajouter une référence' })
diff --git a/docs/development/V1-2-6_R2_LABELS.md b/docs/development/V1-2-6_R2_LABELS.md
index f9b6a539..96a72faa 100644
--- a/docs/development/V1-2-6_R2_LABELS.md
+++ b/docs/development/V1-2-6_R2_LABELS.md
@@ -59,6 +59,7 @@ Règles de lecture :
| `editor.references.reorder_hint` | Pour réorganiser, affichez l'ordre de la fiche sans recherche. | To reorder, show the sheet order without a search. | Onglet Références, sous la barre d'outils quand « Monter » et « Descendre » sont absents | nouveau | |
| `editor.references.no_result` | Aucune référence ne contient « {q} ». | No reference contains “{q}”. | Onglet Références, état sans résultat | nouveau | {q} est le texte tapé, rogné, repris tel quel (`$&` reste littéral). L'état n'est pas une région live : la ligne de décompte annonce déjà « 0 référence sur N ». |
| `editor.references.no_result_scope` | La recherche porte sur la citation, le DOI et l'URL. | The search covers the citation, the DOI and the URL. | Onglet Références, état sans résultat | nouveau | |
+| `editor.references.outside_search` | Ne correspond pas à la recherche | Does not match the search | Onglet Références, ligne sous l'en-tête d'une tuile affichée hors recherche (épinglée : en édition, après « Terminer », en lecture seule) ; décrit le bouton d'en-tête (`aria-describedby`) | nouveau | EN provisoire. Sans effet sur le décompte ni sur l'état sans résultat. |
## 2. Clés retirées