Repository navigation
fix(layout): render no items for a hidden repeating element - #389
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
A layout stopped rendering with
Input Error: Width or height is missingwhen it had a repeated element ($each) whose$whenwas 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
$whenis false as{}, andrenderLayoutTemplatepassed 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 fromundefinedand fails its own size check, so the whole render is rejected.What changed
renderLayoutTemplatedrops empty objects fromchildrenandelementslists 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.{}for each hidden item, and other users of jempl may rely on that.Testing
spec/constructRenderState.hiddenLoopItems.test.jsrenders 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.$whenfalse for every item: no element without a type, no items, and the sibling is kept.$whentrue only for the second item (i == 1): only that item is rendered.$whentrue: every item is rendered.bun run test(104 files, 2605 tests),bun run lintandbun run check:test-markerspass.mainand passes with this change, with the slot container placed directly in the menu's root container and one level deeper.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 != 1draws the first and third choices. Clicking the second drawn row routes to the third item's section.scripts/run-vt-ci.shin the pinned VT image: both pass, with 0 mismatched images.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".Risks
childrenorelementsno longer gets it. Such an item has no type, so Route Graphics could not render it before either.