Skip to content

Fix line numbers in accordions, and the editor caret and number font - #43

Merged
ericof merged 1 commit into
mainfrom
issue-34
Nov 2, 2026
Merged

ericof merged 1 commit into
mainfrom
issue-34

Conversation

@ericof

@ericof ericof commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Closes #34

Line numbers in an accordion

Prism sizes the line numbers only when it highlights. In a closed accordion panel the code is not displayed at that moment, so each row gets height: 0 and the numbers pile up. This also happens to panels opened from the activeAccordion URL parameter, because they open after the highlight. The plugin only measures again on a window resize.

SyntaxHighlighter now observes its pre with a ResizeObserver and sizes the rows when it has a height. Without ResizeObserver (jsdom) it does nothing.

Editor

  • The caret-color rules used > textarea, which never matched because the editor wraps the textarea. The caret was black in both themes, so it could not be seen on the dark one. The other rules in the > textarea block are also dead, and are left alone: applying background-color: whitesmoke would hide the code.
  • The editor line numbers use the monospaced fonts of the view.

A thicker caret is not included: browsers have no caret width, and caret-shape: block covers the character and reads as overwrite mode.

Accordion in the project

@eeacms/volto-accordion-block is added to the root project and volto.config.js only, not to the package, so the add-on gains no dependency. A new acceptance test uses it to cover a code block in a real panel.

Tests

100 unit tests and 8 acceptance tests pass locally. The acceptance run used a development bundle, so CI is the first run against a production build. Hiding the code during load with ResizeObserver removed left the rows at 0px, on a live page.

Prism measures the line heights when it highlights, and a code block in a
closed accordion panel is not displayed then, so every row got a height of
0 and the numbers piled up. Nothing measured again when the panel opened.
A ResizeObserver on the `pre` now sizes the rows once it is visible.

The accordion add-on joins the development project, not the package, so
the acceptance tests can cover a code block inside a real panel.

In the editor, the `caret-color` rules targeted `> textarea`, but the
textarea is wrapped, so the caret was black on the dark theme. The line
numbers now use the same monospaced fonts as the view.

Closes #34
@ericof
ericof merged commit 997d4c5 into main Nov 2, 2026
9 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.

Fix Code Block numbers inside accordion block

1 participant