entity-entry sizing problem #21

Closed
opened 2026-10-14 13:12:41 +00:00 by Syndria98 · 9 comments
Owner

The divs with the class entity-entry are a little bit wider than the sidebar width (with margins included), so when adding a border to it or making it selected it goes outside of the sidebar div and it does not look good. Can you fix it?

The divs with the class entity-entry are a little bit wider than the sidebar width (with margins included), so when adding a border to it or making it selected it goes outside of the sidebar div and it does not look good. Can you fix it?
Syndria98 added the ai-ready label 2026-10-14 13:12:41 +00:00
Agent added the working label 2026-10-14 14:46:59 +00:00
Collaborator

I'll start by finding where entity-entry is used and styled.

I'll start by finding where `entity-entry` is used and styled.
Collaborator

Now I understand the cause. .entity-entry are divs (unlike the note/folder rows, which are buttons) with width: 100% plus padding and border, and there is no global box-sizing reset — so their border box is 22px wider than the sidebar's content box and spills past its edge.

Now I understand the cause. `.entity-entry` are `div`s (unlike the note/folder rows, which are `button`s) with `width: 100%` plus padding and border, and there is no global `box-sizing` reset — so their border box is 22px wider than the sidebar's content box and spills past its edge.
Collaborator

There's an established convention for frontend layout tests in this repo (tests/map-viewer.test.js asserts on the SFC style rules). I'll add a matching regression test for this issue.

There's an established convention for frontend layout tests in this repo (`tests/map-viewer.test.js` asserts on the SFC style rules). I'll add a matching regression test for this issue.
Collaborator

The test's declaration lookup caught the word "box-sizing" in my CSS comment. I'll strip comments before asserting.

The test's declaration lookup caught the word "box-sizing" in my CSS comment. I'll strip comments before asserting.
Collaborator

Let me confirm the new test actually catches the old bug (temporarily reverting, then restoring).

Let me confirm the new test actually catches the old bug (temporarily reverting, then restoring).
Collaborator

Fixed. The cause was a box-sizing problem, not a margin one.

Diagnosis (frontend/app/components/partials/ContentSidebar.vue)

The actor / item / map rows are div.entity-entry with width: 100% plus padding: 9px 10px and border: 1px. The app ships no global box-sizing reset (only .fold-handle::before sets it in main.scss), so those rows used the default content-box: their border box was the sidebar list's content width + 22px, spilling past the sidebar's edge and forcing a horizontal scrollbar in .sidebar-list-drop-wrap. The note and folder rows next to them never showed the problem because they are <button> elements, which is why only the actors / items / maps sections looked wrong.

Change (styles only, no markup or logic touched)

  • .entity-entry: added box-sizing: border-box (plus min-width: 0) so the padding and the border are measured inside the sidebar width — the hover border and the anchored-map border now sit flush inside the sidebar instead of outside it. This matches the neighbouring .sidebar-header and .sidebar-list-drop-wrap, which already declare box-sizing: border-box.
  • .entity-entry-name / .entity-entry-name-row: added min-width: 0 and word-break: break-word (same guard .sidebar-title uses) so a long unbreakable name can no longer push content out of the sidebar either.
  • The hover/anchored states already used a transparent resting border, so they only recolour it — no width change, left as is.

Test — added tests/sidebar-entity-entry.test.js, following the existing convention in tests/map-viewer.test.js (assertions on the SFC's style rules, no dependencies). It checks the list container is border-box sized, every section renders its entries inside that list, .entity-entry sizes its padding and border inside width: 100%, the hovered/anchored states recolour rather than widen the border, and long names wrap.

npm test → 34 tests, 34 pass, 0 fail. I also verified the new test is a real regression test: with the CSS reverted it fails 2 of its 5 checks, and it passes against the fixed file. I did not run the Nuxt dev server to eyeball the sidebar (no node_modules installed in this checkout).

Fixed. The cause was a box-sizing problem, not a margin one. **Diagnosis** (`frontend/app/components/partials/ContentSidebar.vue`) The actor / item / map rows are `div.entity-entry` with `width: 100%` **plus** `padding: 9px 10px` and `border: 1px`. The app ships no global `box-sizing` reset (only `.fold-handle::before` sets it in `main.scss`), so those rows used the default `content-box`: their border box was the sidebar list's content width **+ 22px**, spilling past the sidebar's edge and forcing a horizontal scrollbar in `.sidebar-list-drop-wrap`. The note and folder rows next to them never showed the problem because they are `<button>` elements, which is why only the actors / items / maps sections looked wrong. **Change** (styles only, no markup or logic touched) - `.entity-entry`: added `box-sizing: border-box` (plus `min-width: 0`) so the padding and the border are measured inside the sidebar width — the hover border and the anchored-map border now sit flush inside the sidebar instead of outside it. This matches the neighbouring `.sidebar-header` and `.sidebar-list-drop-wrap`, which already declare `box-sizing: border-box`. - `.entity-entry-name` / `.entity-entry-name-row`: added `min-width: 0` and `word-break: break-word` (same guard `.sidebar-title` uses) so a long unbreakable name can no longer push content out of the sidebar either. - The hover/anchored states already used a transparent resting border, so they only recolour it — no width change, left as is. **Test** — added `tests/sidebar-entity-entry.test.js`, following the existing convention in `tests/map-viewer.test.js` (assertions on the SFC's style rules, no dependencies). It checks the list container is border-box sized, every section renders its entries inside that list, `.entity-entry` sizes its padding and border inside `width: 100%`, the hovered/anchored states recolour rather than widen the border, and long names wrap. `npm test` → **34 tests, 34 pass, 0 fail**. I also verified the new test is a real regression test: with the CSS reverted it fails 2 of its 5 checks, and it passes against the fixed file. I did not run the Nuxt dev server to eyeball the sidebar (no `node_modules` installed in this checkout).
Collaborator

Implementation is ready for review: #24

Implementation is ready for review: https://git.aranroig.com/Syndria98/dragonroll/pulls/24
Agent added help wanted and removed working labels 2026-10-14 14:52:18 +00:00
Author
Owner

How does these tests work?

How does these tests work?
Agent added the working label 2026-10-14 16:16:52 +00:00
Collaborator

No code changes needed for this one — it's a question, so here's how the test file works.

tests/sidebar-entity-entry.test.js

It is a text test, not a browser test. The repo has no frontend test setup: the root package.json only has concurrently, npm test is node --test tests/ (Node's built-in runner, zero dependencies), and there's no jsdom/Vitest/Playwright anywhere. So, exactly like the existing tests/map-viewer.test.js does for the create-map window, my test reads ContentSidebar.vue as a string and asserts on the CSS rules it contains.

The two helpers do all the work:

  • ruleFor(selector) — one regex, \.<selector>\s*\{([^}]*)\}, pulls a single style rule out of the file, then strips any /* ... */ comments from it (comments explain a rule, they aren't part of it — without this, my explanatory comment above box-sizing was itself being read as a declaration). The pattern is deliberately anchored on \s*\{ right after the class name, so .entity-entry cannot accidentally match .entity-entry:hover, .entity-entry.anchored or .entity-entry-name — those need their own escaped selector.
  • declaration(rule, property) — reads the value of one property inside that rule. border: is a literal colon, so it never picks up border-radius: or border-color:.

What the five checks assert, and why each one matters:

Test Guards against
the sidebar list is border-box sized .sidebar-list-drop-wrap's fixed 280px must include its own 10px padding, otherwise the entries' 100% resolves against the wrong box
every section renders its entries inside the list the entity-entry divs are really children of that wrapper (matched by taking the template text from the wrapper to the closing </aside> and counting class="entity-entry", expecting ≥3 for actors/items/maps) — if they were moved elsewhere the sizing rule no longer applies
the entry measures padding and border inside its width the actual fix: given width: 100% plus padding plus border, box-sizing must be border-box. This is the one that regressed the bug
hovered/anchored states keep the same size those states must only set border-color: and never a px border:/border-width: — and the resting border must stay transparent, not none, so showing it doesn't add 2px
a long name wraps .entity-entry-name needs word-break/overflow-wrap, otherwise one unbreakable name pushes content out of the sidebar again

Running it:

npm test                              # whole suite (34 tests, all pass here)
node --test tests/sidebar-entity-entry.test.js

Its limits, honestly: it asserts on declared CSS, not on rendered pixels — it can't measure the sidebar or prove the border is visually inside it, and it won't catch a future rule that reintroduces overflow with a different mechanism (e.g. a negative margin or calc() width). Its value is that it pins the specific cause. I checked that it isn't a vacuous test: with the CSS fix reverted it fails 2 of its 5 checks (an entity entry measures its padding and border inside the sidebar width and a long entry name wraps...), and passes with the fix in. If you'd rather have a real rendered check, that needs a browser runner (Playwright/Vitest + jsdom won't do layout) — say the word and I'll add one, but that means adding dev dependencies to the frontend, which the repo currently avoids.

No code changes needed for this one — it's a question, so here's how the test file works. ## `tests/sidebar-entity-entry.test.js` **It is a text test, not a browser test.** The repo has no frontend test setup: the root `package.json` only has `concurrently`, `npm test` is `node --test tests/` (Node's built-in runner, zero dependencies), and there's no jsdom/Vitest/Playwright anywhere. So, exactly like the existing `tests/map-viewer.test.js` does for the create-map window, my test reads `ContentSidebar.vue` **as a string** and asserts on the CSS rules it contains. **The two helpers do all the work:** - `ruleFor(selector)` — one regex, `\.<selector>\s*\{([^}]*)\}`, pulls a single style rule out of the file, then strips any `/* ... */` comments from it (comments explain a rule, they aren't part of it — without this, my explanatory comment above `box-sizing` was itself being read as a declaration). The pattern is deliberately anchored on `\s*\{` right after the class name, so `.entity-entry` cannot accidentally match `.entity-entry:hover`, `.entity-entry.anchored` or `.entity-entry-name` — those need their own escaped selector. - `declaration(rule, property)` — reads the value of one property inside that rule. `border:` is a literal colon, so it never picks up `border-radius:` or `border-color:`. **What the five checks assert, and why each one matters:** | Test | Guards against | |---|---| | the sidebar list is border-box sized | `.sidebar-list-drop-wrap`'s fixed 280px must include its own 10px padding, otherwise the entries' `100%` resolves against the wrong box | | every section renders its entries inside the list | the `entity-entry` divs are really children of that wrapper (matched by taking the template text from the wrapper to the closing `</aside>` and counting `class="entity-entry"`, expecting ≥3 for actors/items/maps) — if they were moved elsewhere the sizing rule no longer applies | | the entry measures padding and border inside its width | the actual fix: given `width: 100%` **plus** `padding` **plus** `border`, `box-sizing` must be `border-box`. This is the one that regressed the bug | | hovered/anchored states keep the same size | those states must only set `border-color:` and never a px `border:`/`border-width:` — and the resting border must stay `transparent`, not `none`, so showing it doesn't add 2px | | a long name wraps | `.entity-entry-name` needs `word-break`/`overflow-wrap`, otherwise one unbreakable name pushes content out of the sidebar again | **Running it:** ```bash npm test # whole suite (34 tests, all pass here) node --test tests/sidebar-entity-entry.test.js ``` **Its limits, honestly:** it asserts on declared CSS, not on rendered pixels — it can't measure the sidebar or prove the border is visually inside it, and it won't catch a future rule that reintroduces overflow with a *different* mechanism (e.g. a negative margin or `calc()` width). Its value is that it pins the specific cause. I checked that it isn't a vacuous test: with the CSS fix reverted it fails 2 of its 5 checks (`an entity entry measures its padding and border inside the sidebar width` and `a long entry name wraps...`), and passes with the fix in. If you'd rather have a real rendered check, that needs a browser runner (Playwright/Vitest + jsdom won't do layout) — say the word and I'll add one, but that means adding dev dependencies to the frontend, which the repo currently avoids.
Agent removed the working label 2026-10-14 16:17:24 +00:00
Sign in to join this conversation.
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Syndria98/dragonroll#21