Skip to content

fix(layout): render no items for a hidden repeating element - #389

Merged
han4wluc merged 3 commits into
mainfrom
fix/drop-hidden-repeated-layout-items
Nov 16, 2026
Merged

han4wluc merged 3 commits into
mainfrom
fix/drop-hidden-repeated-layout-items

Conversation

@han4wluc

@han4wluc han4wluc commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Why

A layout stopped rendering with Input Error: Width or height is missing when it had a repeated element ($each) whose $when was false. In RouteVN Creator this happens when a Save/Load Slot, Choice Item, Dialogue Line or History Line container has a visibility condition that is false, for example "Auto mode is on". Opening a Save menu like that from Preview shows "Something went wrong while playing the preview." and the menu never appears.

jempl renders each item of a loop whose $when is false as {}, and renderLayoutTemplate passed these items on. Route Graphics cannot parse an element without a type and leaves it as it is. The parent container then computes its size from undefined and fails its own size check, so the whole render is rejected.

What changed

  • renderLayoutTemplate drops empty objects from children and elements lists after rendering, at every depth, and copies only the objects it changes. This covers every surface that renders a layout template: background, visual, dialogue, choice, form, control, layout, overlay and confirm dialog.
  • Only element lists are filtered. Other arrays, such as values that come from template data, are left as they are, because an empty object there can be real data.
  • The version is bumped to 1.52.1.
  • jempl is not changed. Its loops deliberately keep a {} for each hidden item, and other users of jempl may rely on that.

Testing

  • New spec/constructRenderState.hiddenLoopItems.test.js renders a layout on all nine surfaces. Each layout has a repeated container twice: once inside a parent container next to a sibling element, and once at the top level of the layout.
    • $when false for every item: no element without a type, no items, and the sibling is kept.
    • $when true only for the second item (i == 1): only that item is rendered.
    • $when true: every item is rendered.
    • With the source change reverted, the first two tests fail. The first finds 36 empty objects.
  • bun run test (104 files, 2605 tests), bun run lint and bun run check:test-markers pass.
  • RouteVN Creator on the web, with this change built and used in place of the published 1.52.0 for this check only, in a new project from the default template. The Save menu's Save/Load Slot container was given the visibility condition "Auto mode is on", and Save was opened from Preview's control bar. With 1.52.0 this shows the error above. With this change the Save menu opens without its slots and no error.
  • The same layout rendered in Node through Creator's layout projection, this engine and the Route Graphics 1.50.2 parsers: parsing fails on main and passes with this change, with the slot container placed directly in the menu's root container and one level deeper.
  • Two new VT specs, added to the CI VT matrix:
    • robustness/layout-each-hidden-save-slots.yaml: a control button opens a save overlay whose slot rows have $when: variables.showSlots == true. The overlay draws its title, Show Slots and Close without the slots. Show Slots works, and the three slots are then drawn.
    • robustness/layout-each-hidden-choice-item.yaml: a choice layout whose items have $when: i != 1 draws the first and third choices. Clicking the second drawn row routes to the third item's section.
    • Run locally with scripts/run-vt-ci.sh in the pinned VT image: both pass, with 0 mismatched images.
    • With the engine built from main, both fail. The save spec stays on the dialogue screen because the overlay is never drawn: its screenshots differ from the references, and the slot assertion after Show Slots fails. The choice spec stops at "VT BOOTSTRAP FAILED … Input Error: Width or height is missing".
  • A valid layout renders the same as before. The existing VT jobs pass in this PR's checks.

Risks

  • A layout that relied on an empty object in children or elements no longer gets it. Such an item has no type, so Route Graphics could not render it before either.

A layout element with both `$each` and a `$when` that is false rendered
one empty object per item: jempl keeps a `{}` for each loop item whose
`$when` is false. Route Graphics cannot parse an element without a type,
so the parent container failed with "Input Error: Width or height is
missing" and the whole render was rejected.

renderLayoutTemplate now drops these empty items from `children` and
`elements` lists, so every layout surface (background, visual,
dialogue, choice, form, control, layout, overlay and confirm dialog)
renders no items for the hidden element.
Two robustness specs, both run in CI:

- layout-each-hidden-save-slots: a save overlay whose slot rows have a
  false $when draws its title and buttons, its Show Slots button works,
  and the three slots are drawn once the condition is true.
- layout-each-hidden-choice-item: a choice layout that hides its second
  item draws the other two, and the row after the hidden item routes to
  its own section.
@han4wluc
han4wluc merged commit 7532d55 into main Nov 16, 2026
48 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.

1 participant