diff --git a/apps/app/e2e/shell/editor-more-menu.spec.ts b/apps/app/e2e/shell/editor-more-menu.spec.ts
index 69e7f376..41b82586 100644
--- a/apps/app/e2e/shell/editor-more-menu.spec.ts
+++ b/apps/app/e2e/shell/editor-more-menu.spec.ts
@@ -12,6 +12,7 @@ import {
draftPath,
draftTitle,
editorActor,
+ morePlus,
pointOf,
seedDraft,
shapeWith,
@@ -40,8 +41,7 @@ async function openAt(page: Page, width: number, height = 800) {
).toBeVisible()
}
-const more = (page: Page) =>
- page.getByRole('button', { name: dict['editor.tab.more'], exact: true })
+const more = (page: Page) => morePlus(page, dict)
const list = (page: Page) => page.locator('#editor-tabs-more')
/** The boxes that must not move when « Plus » opens: the row, the page below it, the document. */
@@ -90,6 +90,41 @@ test.describe('« Plus » dropdown', () => {
})
}
+ for (const width of [375, 320]) {
+ test(`at ${width} px the entries stack in tab order inside the viewport`, async ({
+ page,
+ }) => {
+ await openAt(page, width)
+ await expect(page.getByRole('tablist').getByRole('tab')).toHaveText([
+ dict['editor.tab.general'],
+ dict['editor.tab.annotations'],
+ ])
+ await more(page).click()
+ const rows = list(page).getByRole('button')
+ await expect(rows).toHaveCount(3)
+ // Vérification may carry its error count.
+ await expect(rows).toHaveText([
+ dict['editor.tab.findings'],
+ dict['editor.tab.references'],
+ new RegExp(`^${dict['editor.tab.verification']}`),
+ ])
+ const boxes = await rows.evaluateAll((els) =>
+ els.map((el) => el.getBoundingClientRect().toJSON()),
+ )
+ boxes.forEach((box, at) => {
+ expect(box.height, `row ${at} height`).toBeGreaterThanOrEqual(44)
+ expect(box.x, `row ${at} left`).toBeGreaterThanOrEqual(0)
+ expect(box.right, `row ${at} right`).toBeLessThanOrEqual(width)
+ if (at > 0) {
+ expect(box.y, `row ${at} below`).toBeGreaterThanOrEqual(
+ boxes[at - 1].bottom,
+ )
+ }
+ })
+ await expectAccessible(page, `« Plus » list at ${width} px`)
+ })
+ }
+
test('closes on a selection, outside tap and Escape, focus kept sane', async ({
page,
}) => {
diff --git a/apps/app/e2e/support/editor.ts b/apps/app/e2e/support/editor.ts
index 4c4eb329..e4e53f0e 100644
--- a/apps/app/e2e/support/editor.ts
+++ b/apps/app/e2e/support/editor.ts
@@ -345,13 +345,34 @@ export const TABS = [
/** The Annotations sections and the panel, in the order the overview offers them. */
export const SECTIONS = ['views', 'categories', 'regions'] as const
+/** Below this width only the tabs of SHOWN_SMALL stay in the row, the others sit under « Plus ». */
+const SMALL_TIER_WIDTH = 640
+const SHOWN_SMALL = ['general', 'annotations']
+
/**
- * Clicks a tab by role. The name is a pattern: the Vérification tab adds « n erreur(s) »
- * to its name while the in-page check has errors.
+ * Clicks a tab by role, whatever the width: from 640 px the tab button, below it « Plus »
+ * opened and the tab picked in its list. The name is a pattern: the Vérification tab adds
+ * « n erreur(s) » to its name while the in-page check has errors.
*/
export async function selectTab(page: Page, dict: Dict, tab: string) {
- const name = dict[`editor.tab.${tab}`]
- await page.getByRole('tab', { name: new RegExp(`^${name}( |$)`) }).click()
+ const width = page.viewportSize()?.width ?? SMALL_TIER_WIDTH
+ const name = new RegExp(`^${dict[`editor.tab.${tab}`]}( |$)`)
+ if (width >= SMALL_TIER_WIDTH || SHOWN_SMALL.includes(tab)) {
+ await page.getByRole('tab', { name }).click()
+ return
+ }
+ const more = morePlus(page, dict)
+ if ((await more.getAttribute('aria-expanded')) !== 'true') await more.click()
+ await page.locator('#editor-tabs-more').getByRole('button', { name }).click()
+ // The dropdown fades out: wait for it to be gone before the next move.
+ await expect(page.locator('#editor-tabs-more')).toHaveCount(0)
+}
+
+/** « Plus », located without an exact name: it carries the Vérification error count. */
+export function morePlus(page: Page, dict: Dict): Locator {
+ return page.getByRole('button', {
+ name: new RegExp(`^${dict['editor.tab.more']}( |$)`),
+ })
}
/** The visible place with this `data-place` name; a hidden copy never answers. */
@@ -395,34 +416,12 @@ export function libraryRoot(page: Page): Locator {
return place(page, 'references')
}
-/** Below this width the tabs other than Annotations and Vérification sit under « Plus ». */
-const SMALL_TIER_WIDTH = 640
-
/**
- * Shows a tab whatever the width: the tab button from 640 px, below it « Plus » opened and
- * the tab picked in its list. Waits for the tab's place to be visible (Annotations names
- * its sections, so any of them).
+ * Shows a tab whatever the width (selectTab). Waits for the tab's place to be visible
+ * (Annotations names its sections, so any of them).
*/
export async function openTab(page: Page, dict: Dict, tab: string) {
- const width = page.viewportSize()?.width ?? SMALL_TIER_WIDTH
- const name = new RegExp(`^${dict[`editor.tab.${tab}`]}( |$)`)
- const listed = ['annotations', 'verification'].includes(tab)
- if (width < SMALL_TIER_WIDTH && !listed) {
- const more = page.getByRole('button', {
- name: dict['editor.tab.more'],
- exact: true,
- })
- if ((await more.getAttribute('aria-expanded')) !== 'true')
- await more.click()
- await page
- .locator('#editor-tabs-more')
- .getByRole('button', { name })
- .click()
- // The dropdown fades out: wait for it to be gone before the next move.
- await expect(page.locator('#editor-tabs-more')).toHaveCount(0)
- } else {
- await page.getByRole('tab', { name }).click()
- }
+ await selectTab(page, dict, tab)
await expect(
tab === 'annotations'
? page.locator('[data-place^=annotations]:visible').first()
diff --git a/apps/app/src/components/editor/EditorTabs.tsx b/apps/app/src/components/editor/EditorTabs.tsx
index 85c60993..eb4d2096 100644
--- a/apps/app/src/components/editor/EditorTabs.tsx
+++ b/apps/app/src/components/editor/EditorTabs.tsx
@@ -15,6 +15,7 @@ import {
type EditorTabId,
} from '@/editor/tabs'
import type { TabTier } from '@/editor/useViewport'
+import Icon from '@/components/ui/Icon'
import { useT } from '@/i18n/useT'
import HistoryButtons from './HistoryButtons'
import { MORE_LIST_ID, useMoreDismiss, useMoreMenu } from './useMoreMenu'
@@ -26,15 +27,25 @@ const ACTIVE =
const IDLE =
'border-transparent text-[var(--color-ink-muted)] hover:text-[var(--color-ink)]'
+const ROW =
+ 'flex min-h-12 w-full items-center justify-between gap-3 rounded-md px-4 text-left text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-accent)]'
+const ROW_ACTIVE =
+ 'bg-[var(--color-accent)]/10 font-medium text-[var(--color-accent-strong)]'
+
/** The blocking-error count on the Vérification tab, as text; absent at zero. */
function ErrorCount({ tab }: { tab: EditorTabId }) {
+ return tab === 'verification' ? : null
+}
+
+/** The count badge itself; also shown on « Plus » while Vérification sits under it. */
+function ErrorBadge() {
const plural = usePlural()
const count = useEditorStore(
(s) =>
s.previewState?.report.issues.filter((i) => i.severity === 'error')
.length ?? 0,
)
- if (tab !== 'verification' || count === 0) return null
+ if (count === 0) return null
return (
<>
{' '}
@@ -127,19 +138,22 @@ function MoreList({ more, active, onPick }: MoreListProps) {
transition: { duration: reduced ? 0 : 0.15 },
}}
exit={{ ...hidden, transition: { duration: reduced ? 0 : 0.12 } }}
- className="absolute inset-x-0 top-full z-20 flex flex-wrap gap-1 border border-[var(--color-border)] bg-[var(--color-surface)] p-1 shadow-md"
+ className="absolute inset-x-0 top-full z-20 mt-1 flex flex-col gap-1 rounded-lg border border-[var(--color-border)] bg-[var(--color-surface)] p-2 shadow-lg"
>
{more.map((tab) => (
))}
@@ -169,7 +183,7 @@ function usePanelPick(
}
}
-/** Below 640 px: « Plus » and its dropdown of the tabs that do not fit. */
+/** Below 640 px: « Plus » (with the Vérification count) and its list of the other tabs. */
function MoreTabs({ more, active, onSelect }: MoreTabsProps) {
const t = useT()
const { open, close, toggle } = useMoreMenu(active)
@@ -186,6 +200,7 @@ function MoreTabs({ more, active, onSelect }: MoreTabsProps) {
className={`-mb-px ${BASE} ${more.includes(active) ? ACTIVE : IDLE}`}
>
{t('editor.tab.more')}
+ {more.includes('verification') && }
{open && }
@@ -202,8 +217,8 @@ interface EditorTabsProps {
/**
* The draft's tab row (boards 04 and 05): the five tabs from 640 px (the row may wrap
- * between 640 and 1 023 px, never scroll sideways), Annotations and
- * Vérification below it with « Plus » opening a dropdown overlay of the others (no measurement).
+ * between 640 and 1 023 px, never scroll sideways), Général and Annotations below it with
+ * « Plus » opening a vertical dropdown overlay of the others, in the same order (no measurement).
* « Défaire » and « Refaire » sit at the right end of the row on every tab.
*/
export default function EditorTabs({
diff --git a/apps/app/src/components/editor/EditorWorkspace.tsx b/apps/app/src/components/editor/EditorWorkspace.tsx
index dfd8f4a4..7edf5c0f 100644
--- a/apps/app/src/components/editor/EditorWorkspace.tsx
+++ b/apps/app/src/components/editor/EditorWorkspace.tsx
@@ -187,9 +187,9 @@ function useShowRestored(nav: EditorNavigation) {
* confirmation before a history jump leaves with a dirty dialog, and whether the last
* editor left a dirty dialog behind.
*/
-function useWorkspaceNavigation(sheetId: string, tier: TabTier, who: Who) {
+function useWorkspaceNavigation(sheetId: string, who: Who) {
const previewState = useEditorStore((s) => s.previewState)
- const tab = previewState ? initialTab(previewState, tier) : 'annotations'
+ const tab = previewState ? initialTab(previewState) : 'annotations'
const owner = useOwner(sheetId, who.tag)
const nav = useEditorNavigation(tab, useRestoredView(owner))
useEditorHistory(nav, owner, defaultView(tab))
@@ -212,11 +212,7 @@ function LeftDraftNotice({ shown }: { shown: boolean }) {
*/
function Workspace(props: Props & Who) {
const { sheet, mode, readOnly } = props
- const { nav, left } = useWorkspaceNavigation(
- sheet.sheet_id,
- props.tier,
- props,
- )
+ const { nav, left } = useWorkspaceNavigation(sheet.sheet_id, props)
return (
diff --git a/apps/app/src/editor/tabs.ts b/apps/app/src/editor/tabs.ts
index 9b7aa5df..05deece2 100644
--- a/apps/app/src/editor/tabs.ts
+++ b/apps/app/src/editor/tabs.ts
@@ -14,11 +14,11 @@ export const EDITOR_TABS = [
] as const
export type EditorTabId = (typeof EDITOR_TABS)[number]
-/** Board 05: the tabs shown beside « Plus » at each width; the rest sit under « Plus ». */
+/** The tabs shown beside « Plus » at each width; the rest sit under « Plus », in tab order. */
const SHOWN: Record = {
wide: EDITOR_TABS,
medium: EDITOR_TABS,
- small: ['annotations', 'verification'],
+ small: ['general', 'annotations'],
}
export function tabsFor(tier: TabTier): {
@@ -31,13 +31,12 @@ export function tabsFor(tier: TabTier): {
/**
* The tab a version opens on: Annotations once a view can be annotated, Général while
- * there is nothing to annotate yet. A tier that does not list Général keeps Annotations.
+ * there is nothing to annotate yet. Both are shown at every width.
*/
-export function initialTab(state: PreviewState, tier: TabTier): EditorTabId {
+export function initialTab(state: PreviewState): EditorTabId {
const unmeasured = unmeasuredViews(state)
const measurable = state.document.views.some((v) => !unmeasured.has(v.id))
- const wanted = measurable ? 'annotations' : 'general'
- return SHOWN[tier].includes(wanted) ? wanted : 'annotations'
+ return measurable ? 'annotations' : 'general'
}
/**
diff --git a/apps/app/tests/unit/editor-initial-tab.test.ts b/apps/app/tests/unit/editor-initial-tab.test.ts
index 78607eca..aef4b595 100644
--- a/apps/app/tests/unit/editor-initial-tab.test.ts
+++ b/apps/app/tests/unit/editor-initial-tab.test.ts
@@ -28,14 +28,10 @@ async function stateOf(text: string) {
describe('initialTab', () => {
it('opens an empty new draft on Général', async () => {
- expect(initialTab(await stateOf(emptyText()), 'wide')).toBe('general')
+ expect(initialTab(await stateOf(emptyText()))).toBe('general')
})
it('opens a draft with a measured view on Annotations', async () => {
- expect(initialTab(await stateOf(baseText()), 'wide')).toBe('annotations')
- })
-
- it('keeps Annotations on a tier that does not list Général', async () => {
- expect(initialTab(await stateOf(emptyText()), 'small')).toBe('annotations')
+ expect(initialTab(await stateOf(baseText()))).toBe('annotations')
})
})
diff --git a/apps/app/tests/unit/editor-mode.test.ts b/apps/app/tests/unit/editor-mode.test.ts
index 69bc2df0..c177b470 100644
--- a/apps/app/tests/unit/editor-mode.test.ts
+++ b/apps/app/tests/unit/editor-mode.test.ts
@@ -106,11 +106,11 @@ describe('tabsFor', () => {
'references',
'verification',
])
- expect(tabsFor('small').shown).toEqual(['annotations', 'verification'])
+ expect(tabsFor('small').shown).toEqual(['general', 'annotations'])
expect(tabsFor('small').more).toEqual([
- 'general',
'findings',
'references',
+ 'verification',
])
})
})
diff --git a/apps/app/tests/unit/editor-more-menu.test.tsx b/apps/app/tests/unit/editor-more-menu.test.tsx
index d9c0ad4d..78824f5f 100644
--- a/apps/app/tests/unit/editor-more-menu.test.tsx
+++ b/apps/app/tests/unit/editor-more-menu.test.tsx
@@ -49,7 +49,7 @@ function Page({
/>