fix: merge partial style overrides into the defaults - #36
Merged
Conversation
Overriding a single style property replaced the entire style object, so
`focusPoint: { style: { width: "40px" } }` left the marker with no border,
shadow or background — the element creation code then assigned `undefined`
to each of them. Callers had to restate every default to change one of
them, and nothing said so.
The style objects are now merged a level deeper than the rest of the
options, so an override layers onto the defaults. `enabled` and the other
scalar keys are untouched.
Four of the five new tests fail against the previous behaviour.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
killerwolf
added a commit
that referenced
this pull request
Sep 6, 2026
The declarations documented the shallow-merge behaviour these comments were written against. #36 fixes that merge, so the note that a partial override unsets everything it omits no longer holds. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
Found while writing the TypeScript declarations in #33.
The bug
The constructor spread user options one level too shallow:
So this:
left
styleas{ width: "40px" }and nothing else._createFocusMarker()then assignedmarker.style.border = undefined,boxShadow = undefined,backgroundColor = undefined— so instead of a slightly larger marker you got one with no border, no shadow and no fill.cropZone.styleandcropZone.handleStylehad the same problem, affecting the crop overlay and all eight resize handles.To change one property you had to restate every default, and nothing in the docs or the types said so.
The fix
The two style objects are merged a level deeper than the rest of the options, so an override layers onto the defaults.
enabledand any other scalar keys keep behaving exactly as before. Passing nostyleat all, or an explicitundefined, leaves the defaults intact.Tests
Five new cases: a partial override on the focus marker, the crop overlay and a resize handle, plus one guarding that scalar options still pass through and one for the no-style-given path.
I checked these actually catch the bug — reverting the source fix and re-running fails four of the five:
Follow-up in #33
src/index.d.tsdoes not exist onmainyet — it is part of #33, where the doc comments onFocusPointStyle,CropZoneStyleandCropHandleStylecurrently describe the replace-wholesale behaviour this PR removes. I have updated those comments on the #33 branch, so whichever merges second is consistent.npm run types:checkalso lives in #33 and could not be run here; it passes on that branch with the updated comments.Verification
npm test(18 passing),npm run lint:checkandnpm run format:checkgreen.🤖 Generated with Claude Code