Skip to content

fix(ui): apply flexbox layout to headings#434

Draft
OverSamu wants to merge 2 commits into
iamgio:mainfrom
OverSamu:issue-433
Draft

fix(ui): apply flexbox layout to headings#434
OverSamu wants to merge 2 commits into
iamgio:mainfrom
OverSamu:issue-433

Conversation

@OverSamu
Copy link
Copy Markdown
Contributor

@OverSamu OverSamu commented Mar 29, 2026

Closes #433.

In Playwright tests I tried to verify that the bounding boxes of the ::before pseudo-element and the inner text did not overlap, but I was unsuccessful as the browser does not appear to expose the ::before element.


Open with Devin

Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 2 potential issues.

View 1 additional finding in Devin Review.

Open in Devin Review

Comment on lines +14 to +15
display: flex;
align-items: flex-start;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔴 display: flex on headings breaks text-align: center in slides documents

Adding display: flex to all headings (h1h6) causes text-align inheritance to no longer control the positioning of heading content. In slides documents, _alignment.scss:39 sets --qd-horizontal-alignment-global: center, which the .quarkdown root inherits as text-align: center (_alignment.scss:2). With display: block (the previous default), this centers the inline text within each heading. With display: flex, text nodes become anonymous flex items whose position is governed by justify-content (defaulting to flex-start), so heading text will appear left-aligned instead of centered. This regression affects slides using the minimal and hyperlegible layout themes (which do not override slides alignment to start). The latex and beamer themes are unaffected because they explicitly set --qd-horizontal-alignment-global: start for .quarkdown-slides.

Fix suggestion

Either scope display: flex to only non-slides documents, or add a compensating rule for slides that sets justify-content: center on headings. For example:

&.quarkdown-slides #{$headings} {
  justify-content: center;
}
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines +14 to +15
display: flex;
align-items: flex-start;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🚩 display: flex may affect heading numbering layout via ::before pseudo-elements

In _location.scss:12-14, heading numbering uses ::before pseudo-elements (e.g. "1.2 "). With display: flex, these ::before pseudo-elements become flex items alongside the heading text. This is likely the intended motivation for this change (to align multiline heading text with the numbering label using flex-start). However, it's worth verifying that the ::before numbering still looks correct across all layout themes (especially latex.scss:43-45 which adds padding-right: 0.85rem to the location heading ::before).

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

@iamgio
Copy link
Copy Markdown
Owner

iamgio commented Mar 30, 2026

I actually attempted the same thing in #25 long time ago. Along with what the bot pointed out, flex is a bad layout for a heading because you can have inline formatting in it:

# First _second_
<h1>First <em>second</em></h1>

Without flex (pre-PR):

image

With flex:

image

As you can see, flex sees First and second as layout cells, rather than text, so it ignores the whitespace between them.

The heading tag shouldn't have a flex layout. I can see something like this at rendering level though:

<div style="display: flex">
  <div class="heading-location">::before</div>
  <h1 data-location="1">Title</h1>
</div>

Instead of the current:

<h1 data-location="1">
  ::before
  Title
</h1>

(Note that by ::before I mean the location content set by _location.scss).

Keeping this PR open, feel free to close or update it as you wish.

@iamgio iamgio marked this pull request as draft March 31, 2026 02:58
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.

[Bug] Heading alignment "broken" when text spans multiple lines

2 participants