Skip to content

feat(core/dfn-panel): show citation popup on biblio reference click#5293

Draft
marcoscaceres wants to merge 8 commits into
mainfrom
feat/3345-biblio-popup
Draft

feat(core/dfn-panel): show citation popup on biblio reference click#5293
marcoscaceres wants to merge 8 commits into
mainfrom
feat/3345-biblio-popup

Conversation

@marcoscaceres
Copy link
Copy Markdown
Contributor

Closes #3345

Clicking a bibliography reference (e.g. [FETCH]) now shows a popup panel with the full citation details, using the same panel infrastructure as dfn panels. Multiple references to the same spec share one panel. The popup prevents the default jump to the references section, keeping the reader in context.

marcoscaceres and others added 4 commits May 10, 2026 17:04
Clicking a [[SPEC]] inline reference now shows a dfn-panel-style popup
containing the full citation details (title, authors, publisher, date,
URL) from the rendered references section, instead of navigating to the
bottom of the page.

The biblio panels reuse the existing .dfn-panel CSS infrastructure and
runtime interaction model (show/hide/dock, focus trapping, keyboard nav).
Panel IDs use the scheme `biblio-panel-for-<bib-id>` to avoid collision
with dfn panels. Multiple links that alias to the same bib entry share a
single panel. Clicking prevents the default scroll-to-references navigation.

Closes #3345
The test asserted expect(doc).toBeTruthy() which always passes.
Replace with expect(panel).toBeNull() to verify no panel is created.
@marcoscaceres marcoscaceres requested a review from Copilot May 10, 2026 09:31
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds bibliography-reference (“bibref”) popups using the existing dfn-panel infrastructure, so clicking an inline citation like [FETCH] can show the full rendered reference without jumping to the References section.

Changes:

  • Extend core/dfn-panel to generate and wire up “biblio panels” for inline bibliography links (a.bibref).
  • Update the dfn-panel runtime listener to open the correct biblio panel and suppress default hash navigation.
  • Add styling and a dedicated test suite for biblio panel creation/interaction (including export behavior).

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
tests/spec/core/dfn-panel-spec.js Adds new biblioPanel test coverage for panel creation, ARIA, interaction, and exported docs.
src/styles/dfn-panel.css.js Adds minor styling for a.bibref cursor and spacing for rendered biblio content inside panels.
src/core/dfn-panel.runtime.js Extends runtime event handling to open/close biblio panels from a.bibref interactions.
src/core/dfn-panel.js Generates biblio panels by cloning rendered reference entries and marks bibref links with dialog semantics.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/core/dfn-panel.runtime.js
Comment thread tests/spec/core/dfn-panel-spec.js
@marcoscaceres marcoscaceres requested a review from Copilot May 15, 2026 01:41
@marcoscaceres
Copy link
Copy Markdown
Contributor Author

@copilot CI is failing with one test:

Core — biblioPanel · does not create a panel for a bibref with no rendered entry
Expected [object HTMLDivElement] to be null.

A panel is being created for bibrefs with no rendered entry; please add the missing guard so none is created in that case. Verify locally with pnpm build:w3c && pnpm lint && npx karma start tests/spec/karma.conf.cjs --single-run --browsers ChromeHeadless --grep="does not create a panel for a bibref with no rendered entry".

When a bibliography reference cannot be resolved, render-biblio renders
an <em class="respec-offending-element"> inside the <dd>. Guard
createBiblioPanel against this case by returning null early, so no
popup panel is created for broken references.

Fixes the "does not create a panel for a bibref with no rendered entry"
test failure.

Agent-Logs-Url: https://github.com/speced/respec/sessions/930336ec-de11-4dd3-9f1d-2db41a02a46e

Co-authored-by: marcoscaceres <870154+marcoscaceres@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

Comment thread src/core/dfn-panel.js
const dt = document.getElementById(bibId);
if (!dt) return null;
const dd = dt.nextElementSibling;
if (!dd || dd.tagName !== "DD") return null;
Comment thread src/core/dfn-panel.js Outdated
Comment on lines +43 to +47
const panel = createBiblioPanel(link);
if (panel) panels.append(panel);
}
// All links pointing to the same bibId share the single panel.
link.setAttribute("aria-haspopup", "dialog");
Copy link
Copy Markdown
Contributor

Copilot AI commented May 15, 2026

@copilot CI is failing with one test:

Core — biblioPanel · does not create a panel for a bibref with no rendered entry...

Fixed in d6c16d4. Added a guard in createBiblioPanel that returns null early when the <dd> contains a .respec-offending-element — which is what render-biblio.js renders (<em class="respec-offending-element">Reference not found.</em>) for unresolved references. No panel is created in that case.

@marcoscaceres
Copy link
Copy Markdown
Contributor Author

@copilot can you fix the issues you just found.

Track which bibIds actually have a panel created (panelBibIds set) and
only set aria-haspopup="dialog" on links whose bibId is in that set.
Links for unresolved references (where createBiblioPanel returns null)
no longer advertise a dialog to assistive technologies.

Also extend the "no rendered entry" test to assert aria-haspopup is
absent for such links.

Agent-Logs-Url: https://github.com/speced/respec/sessions/d4845caf-5d7c-43ce-b1b6-93507f35c89e

Co-authored-by: marcoscaceres <870154+marcoscaceres@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI commented May 15, 2026

@copilot can you fix the issues you just found.

Fixed in d45e076. Issue 1 (guard for .respec-offending-element) was already in place from the previous commit. For issue 2, I introduced a panelBibIds set to track which bibIds actually got a panel, and aria-haspopup="dialog" is now only set on links whose bibId is in that set. The "no rendered entry" test also gained an assertion verifying aria-haspopup is absent for unresolved refs.

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.

Clicking on bliblio refs should pop up dfn panel

3 participants