fix(text): skip initDimensions in set when a textLayoutProperty value did not change#11029
Open
jiayihu wants to merge 2 commits into
Open
fix(text): skip initDimensions in set when a textLayoutProperty value did not change#11029jiayihu wants to merge 2 commits into
jiayihu wants to merge 2 commits into
Conversation
Review or Edit in CodeSandboxOpen the branch in Web Editor • VS Code • Insiders |
Contributor
|
Build Stats
|
asturur
reviewed
Jun 29, 2026
| needsDims = | ||
| needsDims || | ||
| (textLayoutProperties.includes(_key) && | ||
| this[_key as keyof this] !== key[_key]); |
Member
|
I just merged a breaking change with the publishing system, i m not able to publish this, if you want this out we need to fork the current release and make a release branch. |
asturur
approved these changes
Jun 29, 2026
Contributor
Author
|
No hurry, we always directly patch or override methods at work, then I just port over the fixes to fabric when I have time |
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.
Disclosure: I found out the issue during work but I fully asked GLM 5.2 to port the fix back to fabric, add tests and open the PR using the repo skill.
Summary
FabricText.set(and subclasses likeTextbox/IText) was requestinginitDimensions()/setCoords()whenever a key intextLayoutPropertieswas passed toset, regardless of whether the value actually changed. Setting a layout property to the same value it already held therefore triggered an unnecessary text re-measurement and coord recomputation. The fix ports the value-changed check (already used inPolyline._set) intoText.setsoinitDimensionsis only requested when a layout-relevant value differs from the current one, while keeping the existing code path that delegates tosuper.set(which calls_set).Changes
src/shapes/Text/Text.ts: inset, computeneedsDimsby comparingthis[key] !== valuebeforesuper.setmutates the instance (for both the string-key and object-key branches).super.setis still called for all keys, andsetPathInfo()still runs after the set when apathkey is present.src/shapes/Text/Text.spec.ts: added two tests under aset & initDimensionsdescribe block — one for the single-keyset('text', ...)no-op vs. change case, and one for the objectset({ text, fontSize, charSpacing })no-op vs. change case — spying oninitDimensions/setCoordsto assert the skip behavior.