Skip to content

feat(display): show the number of subpages at sections - #1824

Merged
perber merged 6 commits into
mainfrom
feat/subpage-count
Nov 15, 2026
Merged

perber merged 6 commits into
mainfrom
feat/subpage-count

Conversation

@perber

@perber perber commented Nov 15, 2026

Copy link
Copy Markdown
Owner

Related issue

Part of #1779 (step 3 of 3; step 1 was #1813, step 2 #1821, the shared display update route #1823). Closes #1779.

What changed

Admins can turn on Settings → Display → Subpage count (default off). Sections then show how many direct subpages they have: in the tree after the title, and in the overview of an empty section at every sub-section. The setting is instance-wide and also applies to anonymous visitors with public access.

  • Count = direct children from the client tree (children.length), so it only counts what the viewer already sees; nothing is counted server side. An empty section shows 0.
  • The visible number is aria-hidden; screen readers get the plural text ("12 subpages"), _one/_other in all 5 locales.
  • Backend: only internal/pagedisplay changes. New showSubpageCount field in Settings/Patch/toc-display.json (missing means off), set through the existing PUT /api/admin/settings/display, delivered via /api/config. No new route.
  • Frontend: shared components/SubpageCount.tsx used by TreeNode and EmptySectionChildrenList; new checkbox section on the Display page. The tree link is now flex with min-w-0, so a long title truncates before the number.
  • Separate refactor(settings) commit first: the per-section saving state and toasts in DisplaySettings.tsx move into one useDisplaySettingSave hook (no behaviour change), so the third setting doesn't copy them again.

How I tested it

  • Go: patch/service (old file without the field, Update keeps other fields, old per-setting setters keep the flag, reload), router (field accepted, bad types 400, anonymous /api/config with and without public access).
  • UI: parser default, hook, Display settings toggle/save/error, TreeNode (off, pages, 0, direct children only, store updates on move and toggle), EmptySectionChildrenList, plural resolution in every locale.
  • e2e settings-subpage-count.spec.ts: admin enables it, tree and overview show the count with the right accessible name; anonymous visitor on a public wiki sees it too.
  • make test, make lint, make verify, make verify-commits, make ui-check.
  • Manual, still to do: light/dark; long section title in a narrow sidebar (title truncates, number stays); 375px width in tree drawer and overview; hover underline in the overview covers only the title.

Checklist

  • I discussed the approach on the linked issue before starting (or this is a trivial fix: typo, docs, obvious one-liner)
  • This PR is focused on a single change
  • New behaviour plugs into an extension point; no new if feature branches in shared code (rule 1)
  • I updated documentation if needed
  • If users or admins will notice a change in behaviour, the commit carries a Behavior-Change: trailer (commit style) (not added: default off, nothing changes until an admin enables it)
  • For UI changes: behaviour is covered by automated tests where possible (rule 11)

🤖 Generated with Claude Code

perber added a commit that referenced this pull request Nov 15, 2026
…1825)

"wide stays aligned next to the expanded TOC side panel" failed in CI on
#1823 (3.7px) and #1824 (25px) without touching the viewer. The TOC pane
and the subheader's reserved padding animate their width over 200ms, and
the spec measured once right after the panel became visible, so content
and header rows could be caught mid-animation. measureViewer now waits
until no CSS transition is running.
Each section of the Display settings page saved its patch with its own
copy of the saving flag, the store call and the success/error toasts.
useDisplaySettingSave holds that once; a section passes its two messages
and gets { saving, save }. No behaviour change.
New instance-wide display setting showSubpageCount (default off), part of #1779.
When an admin turns it on under Settings > Display, section rows in
the tree and sub-sections in the section overview show how many direct
children they have. The count comes from the client tree, which is already
filtered for the viewer, so nothing is counted server side; anonymous
visitors get the setting through /api/config like the other display
settings. The visible number is aria-hidden, screen readers get
"12 subpages".

The setting is a new field in pagedisplay.Settings/Patch and in
toc-display.json (a missing field means off) and is changed through
PUT /api/admin/settings/display; no new route.
Merge the per-field read tests (no file, old files, content width, subpage
count) into one table comparing the whole Settings value, and the per-field
reload tests into one table. No case dropped; coverage stays at 98.1%.
@perber
perber force-pushed the feat/subpage-count branch from 982162d to b19ad77 Compare November 15, 2026 18:57
@perber
perber merged commit 1b77026 into main Nov 15, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Adjustable page width

1 participant