entity-entry sizing problem #21
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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?
I'll start by finding where
entity-entryis used and styled.Now I understand the cause.
.entity-entryaredivs (unlike the note/folder rows, which arebuttons) withwidth: 100%plus padding and border, and there is no globalbox-sizingreset — so their border box is 22px wider than the sidebar's content box and spills past its edge.There's an established convention for frontend layout tests in this repo (
tests/map-viewer.test.jsasserts on the SFC style rules). I'll add a matching regression test for this issue.The test's declaration lookup caught the word "box-sizing" in my CSS comment. I'll strip comments before asserting.
Let me confirm the new test actually catches the old bug (temporarily reverting, then restoring).
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-entrywithwidth: 100%pluspadding: 9px 10pxandborder: 1px. The app ships no globalbox-sizingreset (only.fold-handle::beforesets it inmain.scss), so those rows used the defaultcontent-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: addedbox-sizing: border-box(plusmin-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-headerand.sidebar-list-drop-wrap, which already declarebox-sizing: border-box..entity-entry-name/.entity-entry-name-row: addedmin-width: 0andword-break: break-word(same guard.sidebar-titleuses) so a long unbreakable name can no longer push content out of the sidebar either.Test — added
tests/sidebar-entity-entry.test.js, following the existing convention intests/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-entrysizes its padding and border insidewidth: 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 (nonode_modulesinstalled in this checkout).Implementation is ready for review: #24
How does these tests work?
No code changes needed for this one — it's a question, so here's how the test file works.
tests/sidebar-entity-entry.test.jsIt is a text test, not a browser test. The repo has no frontend test setup: the root
package.jsononly hasconcurrently,npm testisnode --test tests/(Node's built-in runner, zero dependencies), and there's no jsdom/Vitest/Playwright anywhere. So, exactly like the existingtests/map-viewer.test.jsdoes for the create-map window, my test readsContentSidebar.vueas 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 abovebox-sizingwas itself being read as a declaration). The pattern is deliberately anchored on\s*\{right after the class name, so.entity-entrycannot accidentally match.entity-entry:hover,.entity-entry.anchoredor.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 upborder-radius:orborder-color:.What the five checks assert, and why each one matters:
.sidebar-list-drop-wrap's fixed 280px must include its own 10px padding, otherwise the entries'100%resolves against the wrong boxentity-entrydivs are really children of that wrapper (matched by taking the template text from the wrapper to the closing</aside>and countingclass="entity-entry", expecting ≥3 for actors/items/maps) — if they were moved elsewhere the sizing rule no longer applieswidth: 100%pluspaddingplusborder,box-sizingmust beborder-box. This is the one that regressed the bugborder-color:and never a pxborder:/border-width:— and the resting border must staytransparent, notnone, so showing it doesn't add 2px.entity-entry-nameneedsword-break/overflow-wrap, otherwise one unbreakable name pushes content out of the sidebar againRunning it:
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 widthanda 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.