Skip to content

Docx editor react large performance improvement#497

Open
ResiDev wants to merge 6 commits into
eigenpal:mainfrom
ResiDev:docx-editor-perf
Open

Docx editor react large performance improvement#497
ResiDev wants to merge 6 commits into
eigenpal:mainfrom
ResiDev:docx-editor-perf

Conversation

@ResiDev

@ResiDev ResiDev commented May 18, 2026

Copy link
Copy Markdown

Summary

Improves DocxEditor typing performance by reducing unnecessary React rerenders, redundant selection overlay updates, and avoidable layout work.

Changes

  • Preserve selection formatting/context object identity when values are unchanged
  • Stabilize toolbar context values and memoize formatting UI paths
  • Move caret blinking from React state updates to CSS animation
  • Avoid redundant selection overlay state updates
  • Prevent layout-input effects from rerunning on ordinary body edits
  • Keep layout/selection observer callbacks stable so geometry redraws do not trigger extra React work

Verification

  • bun run typecheck
  • bun run build
  • bun test packages/react/src/paged-editor/LayoutSelectionGate.test.ts packages/react/src/paged-editor/PagedEditor.tableMeasure.test.ts
  • bun test
  • bun run lint (passes with existing warnings)
  • bun run format:check
  • Manual typing/profile verification in the editor:
    • Commit durations dropped from roughly 40-70ms spikes to about 17-25ms on my machine
    • The profiler no longer shows the earlier stream of small repeated toolbar/editor rerenders while typing
    • Paged layout and selection overlay work during typing measured in the sub-ms to ~1ms range after the render cleanup

@vercel

vercel Bot commented May 18, 2026

Copy link
Copy Markdown

@ResiDev is attempting to deploy a commit to the EigenPal Team on Vercel.

A member of the Team first needs to authorize it.

@eigenpal-release-pal

eigenpal-release-pal Bot commented May 18, 2026

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅

Posted by the CLA bot.

@ResiDev

ResiDev commented May 18, 2026

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

eigenpal-release-pal Bot added a commit that referenced this pull request May 18, 2026
@jedrazb

jedrazb commented May 20, 2026

Copy link
Copy Markdown
Contributor

Hey @ResiDev could you rebase the PR on main? We have 1.x release and things got slightly re-orged in the repo

@ResiDev ResiDev force-pushed the docx-editor-perf branch from 354c6c9 to 481aaf7 Compare May 20, 2026 21:11
@ResiDev

ResiDev commented May 20, 2026

Copy link
Copy Markdown
Author

Rebased this on current main and pushed the updated branch.

I made some further changes. It focuses on reducing typing-time rerenders by splitting the heavy formatting rail out of DocxEditorToolbar, preserving selectionFormatting identity when the effective formatting has not changed, memoizing stable toolbar picker work, and stabilizing table action handler identities so callback churn does not force toolbar rerenders.

From the local React Profiler typing captures, the main profile went from about 603.5ms total render time across 30 commits (20.1ms avg, 51.3ms max, 14 commits >= 10ms) to 167.6-197.5ms across 26-28 commits (6.0-7.6ms avg, 18.5-33.6ms max, 3-5 commits >= 10ms). So roughly a 67-72% reduction in total render time for this local typing sample.

@ResiDev

ResiDev commented May 20, 2026

Copy link
Copy Markdown
Author

I did also find a fair amount of playwright failing tests - but from the ones that I checked I think they were failing before this commit too.

@vercel

vercel Bot commented May 21, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docx-editor Ready Ready Preview, Comment May 21, 2026 6:52am

Request Review

@ResiDev ResiDev force-pushed the docx-editor-perf branch from 481aaf7 to 289664b Compare May 22, 2026 20:55
@ResiDev

ResiDev commented May 25, 2026

Copy link
Copy Markdown
Author

Is there anything more that you need me to do on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants