fix(core): make MiQ#setTheme() adopt a new preset's own size - #55
Merged
Conversation
setTheme() carried the previous theme's width/height onto any object
input that didn't set its own — meant to preserve an explicit
setSize()/setScale(), but it fired for any object input at all,
including a plain `{ extends: 'portrait', ... }` that never touched
size. Switching to a differently-sized preset that way silently kept
the old canvas's dimensions instead of the new preset's own (e.g.
portrait's 630x790), with no error or warning.
Now MiQ tracks whether width/height were actually set explicitly (via
setSize(), setScale(), or setTheme() itself setting one), and only
those survive a later setTheme() that doesn't set its own size. A
theme picked by name, or an object that does set width/height, is
unambiguous and always wins outright.
Closes #53
4 tasks
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.
Summary
Closes #53.
setTheme()carried the previous theme'swidth/heightonto any object input that didn't set its own — meant to preserve an explicitsetSize()/setScale()call across a later theme tweak, but it fired for any object input, including a plain{ extends: 'portrait', ... }that never touched size at all. Switching to a differently-sized preset that way silently kept the old canvas's dimensions instead of the new preset's own (e.g. portrait's 630×790), with no error or warning — exactly the repro in the issue.Fix:
MiQnow tracks whetherwidth/heightwere set explicitly (viasetSize(),setScale(), orsetTheme()itself setting one), in#explicitWidth/#explicitHeight. Only an explicitly-set dimension survives a latersetTheme()that doesn't set its own size — a theme picked by name, or an object that does setwidth/height, is unambiguous and always wins outright.clone()carries the explicit-size state over too, so a clone behaves the same as its source for a later preset switch.Test plan
vitest run(full suite, 699 tests) — new coverage: adopts a differently-sized preset when nothing was set explicitly, still keeps an explicit size across a later preset switch, a named preset always wins even over an explicit size, an explicit size set viasetTheme()itself survives a later plain override, andclone()carries the explicit size forwardtsc --noEmitbiome checknpm run build+node scripts/check-build.js(55 module-boundary checks pass)