Skip to content

fix(super-editor): guard cached paragraph props lookup in indent commands (SD-3083)#3217

Merged
caio-pizzol merged 3 commits intomainfrom
caio-pizzol/IT-1027
May 10, 2026
Merged

fix(super-editor): guard cached paragraph props lookup in indent commands (SD-3083)#3217
caio-pizzol merged 3 commits intomainfrom
caio-pizzol/IT-1027

Conversation

@caio-pizzol
Copy link
Copy Markdown
Contributor

@caio-pizzol caio-pizzol commented May 10, 2026

Fixes a TypeError thrown by the Increase Indent and Decrease Indent toolbar buttons when fired against a paragraph the rendering pass hadn't visited yet (fresh load, freshly inserted paragraph). The command was reading from a lazy resolved-properties cache without handling a miss.

  • The fix is compute-on-miss, not a ?? {} guard. A bare guard would stop the crash but silently apply the wrong delta when the paragraph's indent baseline comes from a Word style - turning a crash into a wrong number. Compute-on-miss falls back to calculateResolvedParagraphProperties, so the style cascade is honored.
  • Set/Unset Indent skip the resolve work via an opt-in flag. They don't read the current indent. A test locks the opt-out in so a future refactor can't widen the scope by accident.
  • Tests: unit cases for both directions across cache hit, cache miss with empty fallback, and cache miss with style-derived inheritance. A new behavior test exercises the toolbar buttons end-to-end.
  • Closes SD-3083, blocks IT-1027. Source: GitHub Bug: calculateNewIndentation crashes — Cannot destructure property 'indent' of getResolvedParagraphProperties(node) as it is undefined #3208.

…ands (SD-3083)

Increase/Decrease Indent crashed when fired before the rendering pass had
populated the resolved-paragraph-properties cache (fresh load, freshly
inserted paragraphs). Falls back to compute-on-miss so the style cascade
is honored, instead of a bare guard which would stop the crash but apply
the wrong delta on style-derived indents.

Set/Unset commands keep the original code path - they don't read the
current indent and don't need the resolve work.
@caio-pizzol caio-pizzol requested a review from a team as a code owner May 10, 2026 13:24
@linear
Copy link
Copy Markdown

linear Bot commented May 10, 2026

SD-3083

IT-1027

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Unit tests:
- decreaseTextIndent honors style-derived indent on cache miss (symmetric
  to the existing increase regression test)
- Cache hit short-circuits the compute-on-miss fallback - inverse of the
  set/unset opt-out test, guards the production || short-circuit

Behavior test (tests/behavior/tests/toolbar/paragraph-indent.spec.ts):
- Increase Indent on a fresh paragraph adds indent without crashing
- Decrease Indent removes the indent applied by Increase
- Repeated Increase compounds the left indent
Pre-existing typo - example used `unsetTextIndent()` but the function
is `unsetTextIndentation`. Found during a comment audit on this branch.
@caio-pizzol caio-pizzol self-assigned this May 10, 2026
@caio-pizzol caio-pizzol merged commit 7a2f2db into main May 10, 2026
65 checks passed
@caio-pizzol caio-pizzol deleted the caio-pizzol/IT-1027 branch May 10, 2026 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: calculateNewIndentation crashes — Cannot destructure property 'indent' of getResolvedParagraphProperties(node) as it is undefined

2 participants