kolibri icon indicating copy to clipboard operation
kolibri copied to clipboard

Pages keep exactly one H1 while a side panel or Learn's completion modal is open

Open rtibblesbot opened this issue 2 months ago • 10 comments

❌ This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues.

Overview

A page with a visible <h1> has two H1s in the accessibility tree while a kolibri-common SidePanelModal is open over it, because the panel renders its own <h1> and is not aria-modal. Learn's CompletionModal has the same gap over a resource page's hidden <h1>. For #4922, every page should have exactly one H1 in every state.

Complexity: Medium Target branch: develop

Context

  • kolibri-common/components/SidePanelModal is a focus trap with role="presentation" and no aria-modal, so the page behind it stays in the accessibility tree. The courses SidePanelModal is role="dialog" aria-modal="true", so it does not have this gap.
  • useSidePanelTitle (#15394) only drops the hidden <h1> of a page that has none of its own. A page with a visible <h1> keeps it.
  • Repro, Jest on the #15394 branch: render LessonSummaryPage with the real LessonResourceSelection at LESSON_SELECT_RESOURCES: the DOM has the page's exam-title H1 and the panel's side-panel-title H1.
  • Facility's user side panels also render <h1 class="side-panel-title"> inside this SidePanelModal.
  • develop (vue-meta) has the same two H1s, so this is a gap in the new mechanism, not a regression.
  • Learn's CompletionModal renders an <h1> in a role="dialog" with no aria-modal. It is a fork of KModal, so learningequality/kolibri-design-system#1312 and #1331 do not reach it.
  • TopicsContentPage renders a visuallyhidden <h1> from pageHeading behind the completion modal.
  • Repro, Jest on the #15474 branch (TopicsContentPage.spec.js harness): after the content emits finished, the H1s outside [aria-modal="true"] are Resource in a panel - Topic in a panel and Resource completed.

The Change

  • A page with a visible <h1> has one H1 while a kolibri-common SidePanelModal is open over it.
  • The panel keeps an accessible name.
  • A learn resource page has one H1 while its completion modal is open.

Acceptance Criteria

General

  • [ ] While Coach > Plan > Lessons > <lesson> > Manage resources is open, the page has one H1.
  • [ ] After the panel closes, the page's own <h1> is the only H1.
  • [ ] While the completion modal is open after finishing Learn > Library > <channel> > <resource>, the page has one H1.
  • [ ] After the completion modal closes, the page's H1 count is what it was before it opened.
  • [ ] Pages without an open side panel or completion modal are unchanged.

Accessibility and i18n

  • [ ] A screen reader announces the panel's title when it opens.
  • [ ] A screen reader announces "Resource completed" when the completion modal opens.

Testing

  • [ ] A Jest test covers a page with a visible heading before, during and after a SidePanelModal is open.
  • [ ] A Jest test covers a resource page before, during and after the completion modal is open.

References

AI usage

Claude Code found this while reviewing the #15394 branch and drafted the issue; the two-H1 repro was run in Jest.

rtibblesbot avatar Oct 02 '26 15:10 rtibblesbot

@rtibbles one question decides the design: does "one H1" mean one in the DOM, or one in the accessibility tree?

  • A — accessibility tree (recommended): make kolibri-common SidePanelModal role="dialog" aria-modal="true", labelled by its title, like the courses SidePanelModal.
    • Covers all 16 consumers (coach, facility, learn, qti_viewer) in one file, and announces the title on open.
    • The panel's <h1> stays in the DOM, so a DOM count still finds two. Jest does not model aria-modal, so the test asserts the page H1 is the only one outside the modal dialog.
  • B — DOM: the panel renders <h2> while its host has a visible <h1>, and stays labelled by it.
    • Every panel needs to know whether its host has a visible heading. That builds on useSidePanelTitle in #15476, which is unmerged and coach-only, so this would wait for it and still not reach facility or learn.

Also: should this cover every SidePanelModal consumer, or only coach's lesson and quiz resource panels?

rtibblesbot avatar Oct 03 '26 23:10 rtibblesbot

A - for every consumer, so changing it in the base component is ideal.

rtibbles avatar Oct 04 '26 16:10 rtibbles

Design, per the answer above:

  • kolibri-common SidePanelModal's <section> becomes role="dialog" aria-modal="true". The root stays role="presentation".
  • Name: the ariaLabel prop if given, else aria-labelledby to the first heading in the #header slot. That heading gets an id if it has none, and is re-resolved when the header re-renders (e.g. SectionSidePanel's v-if headings).
  • Learn's four metadata panels (BookmarkPage, TopicsContentPage, LibraryPage, TopicsPage) have only chips in the header, so they pass the content title as ariaLabel.
  • No change to any panel's heading level or to useSidePanelTitle (#15476).
  • Tests:
    • SidePanelModal spec: dialog role, aria-modal, and name from the prop or the header heading.
    • LessonSummaryPage spec: before, during and after Manage resources, exactly one H1 outside the modal dialog, and the dialog is named by the panel title.

rtibblesbot avatar Oct 04 '26 17:10 rtibblesbot

Plan: A page with a visible <h1> has one H1 in the accessibility tree while a kolibri-common SidePanelModal is open over it.

  • [ ] Base SidePanelModal is a named modal dialog
  • [ ] Learn metadata panels pass a name
  • [ ] Lesson summary keeps one H1 through Manage resources
  • [ ] Self-review the produced code

Assumptions — the issue did not settle these; say so if one is wrong.

  • LessonSummaryPage.spec.js is created here; #15476 adds the same file, so whichever merges second combines the two.
  • The heading re-resolves in onUpdated; if a panel ever renders its heading in a nested child, the name goes stale and needs a MutationObserver.
  • Learn's metadata panels are named by the content title alone; if the activity kind belongs in the name, ariaLabel must add it.
  • No warning for a panel with neither ariaLabel nor a header heading; if one is wanted, it goes in SidePanelModal.

@rtibblesbot's comments are generated by an LLM, and should be evaluated accordingly

How was this generated?
  • Implemented code following the pre-approved plan using test-driven development (red-green-refactor)
  • Ran the project's full test suite and linter before committing
  • For UI changes: captured live screenshots to verify rendering
  • For backend changes: verified with example API/CLI output

rtibblesbot avatar Oct 04 '26 17:10 rtibblesbot

@rtibbles Blocked — these cannot be assumed either way:

  • aria-modal="true" on SidePanelModal hides controls KDS mounts in #k-overlay (every KSelect listbox, e.g. facility Create user; the appendToOverlay close-confirmation in lesson Manage resources) from AT that enforces it. Which way? - A: keep aria-modal; file a KDS issue for a KSelect mount target, and drop appendToOverlay from LessonResourceSelection (outside this branch's files). - B: drop aria-modal here; the page H1 stays in the accessibility tree while a panel is open, so "one H1" needs another mechanism (e.g. inert on the page).

@rtibblesbot's comments are generated by an LLM, and should be evaluated accordingly

How was this generated?
  • Implemented code following the pre-approved plan using test-driven development (red-green-refactor)
  • Ran the project's full test suite and linter before committing
  • For UI changes: captured live screenshots to verify rendering
  • For backend changes: verified with example API/CLI output

rtibblesbot avatar Oct 04 '26 18:10 rtibblesbot

Sounds like this is blocked by KSelect's behaviour then? So we should file an issue on KDS to make KSelect behave appropriately in these circumstances - which should then block this issue.

Likely the requirement for this issue is that KSelect use newer dropdown handling that KDropdownMenu uses, for example?

rtibbles avatar Oct 04 '26 18:10 rtibbles

@rtibbles Blocked — these cannot be assumed either way:

  • Manage resources opens with focus on Close while the dialog has no name, which fails "A screen reader announces the panel's title when it opens". The panel title is '' until SelectionIndex mounts after the channel fetch. May this branch change files outside its current set? - Yes: start title at defaultTitle in LessonResourceSelection/index.vue:257 and QuizResourceSelection/index.vue:564, and assert the name at focus time with the fetch still pending. - No: leave that criterion to a follow-up issue.

Written by rtibblesbot, an LLM-based coding agent.

rtibblesbot avatar Oct 04 '26 19:10 rtibblesbot

Yes

rtibbles avatar Oct 04 '26 19:10 rtibbles

@rtibbles Self-review did not converge on this branch, so nothing was pushed, though replies on the PR may describe these changes. The last review was clean, but no second review of the same tree confirmed it.

Reply with direction and another review round runs.


Written by rtibblesbot, an LLM-based coding agent.

rtibblesbot avatar Oct 17 '26 05:10 rtibblesbot

Same gap in Learn's CompletionModal: a learn resource page has two H1s in the accessibility tree while it is open.

  • CompletionModal/index.vue#L13-L35 renders <h1 id="modal-title"> in a role="dialog" with no aria-modal.
  • TopicsContentPage.vue#L58-L63 renders the page's visuallyhidden <h1> behind it.
  • It is a fork of KModal, so learningequality/kolibri-design-system#1312 and #1331 do not reach it.
  • Repro, Jest on this branch (TopicsContentPage.spec.js harness): after the content emits finished, the H1s outside [aria-modal="true"] are Resource in a panel - Topic in a panel and Resource completed.
  • Manual: Learn > Library > <channel> > <resource>, finish it.

Written by rtibblesbot, an LLM-based coding agent.

rtibblesbot avatar Nov 04 '26 04:11 rtibblesbot