Repository navigation
[docs-infra] Keep source inputs stable - #2125
brijeshb42 wants to merge 5 commits into
Conversation
Deploy previewBundle sizeTotal Size Change: 🔺+77KB(+2.35%) - Total Gzip Change: 🔺+28KB(+3.24%) Show details for 80 more bundlesCodeEditor parsed: 🔺+1.35KB(+10.10%) gzip: 🔺+453B(+8.37%) PerformanceNo regressions in 12 benchmarks · precise to ±18.0% (±41.4% at worst) · ran 1m 23s · details Check out the code infra dashboard for more information about this PR. |
03d54d3 to
cc210e0
Compare
3a6cdd0 to
fd6221e
Compare
mui/mui-public#2125 was rebased onto master; point the preview dependency at its new pkg.pr.new build.
Pick up mui/mui-public#2125 after its rebase and mui/material-ui#49910, which mounts the live source editor on interaction instead of after load.
With editActivation 'interaction', a click on the static source loads the editor and focuses its textarea at offset 0, so the first click moves the caret to the start of the file. Map the click point onto the editor's mirror <pre> once it mounts and select that offset. Consumers need this to drop the eager NativeCodeSource mount, whose repaint became LCP on anchored docs pages.
Picks up mui/mui-public#2125, which places the caret at the clicked point when the editor mounts on interaction.
Pick up mui/mui-public#2125 and mui/material-ui#49910: the editor now mounts on the first interaction, with the caret at the clicked point, instead of replacing the static source after load. Update the website specs to that contract.
Pick up mui/mui-public#2125 and mui/material-ui#49910: the editor now mounts on the first interaction, with the caret at the clicked point, instead of replacing the static source after load. Update the website specs to that contract.
Pick up mui/mui-public#2125 and mui/material-ui#49910: the editor now mounts on the first interaction, with the caret at the clicked point, instead of replacing the static source after load. Update the website specs to that contract.
Keep the source input mounted while editing tools load, so the first click can place the caret without idle initialization.
Source inputs render with the page. Opt into
NativeCodeSourcefor full files and contiguous focus snippets. The server renders a readonly textarea with the precomputed highlight; hydration binds editing to the same input. Other renderers keep their existing lazy path.Initialization preserves selection and undo. Before, loading the editor replaced the highlighted preview. After, the input survives parser readiness, composition and typing. Runtime highlighting starts after an edit; initial source uses its precomputed tokens.
Undo respects the source view.
edit snippet → expand → undokeeps the complete file.edit TypeScript → switch to JavaScript → undokeeps JavaScript. Changing views starts a new history; parser initialization preserves the current history.Cold edits retain every file. Editing
FocusedLiveEdit.tsx,message.tsand CSS before the source module loads previously kept only the CSS update. Pending edits now apply in order, preserving caret/focus metadata and the original preview; Reset cancels earlier pending work.Deferred source stays compact. Contiguous source windows travel as a length and indentation when the existing fallback contains the exact text. CRLF or other mismatches retain the exact source. The 612 descriptors from the X build total 29,069 uncompressed bytes; this is added metadata, not a reduction against master.
Tests:
NativeCodeSource.browser.tsx: input identity, first typing, composition, undo and view/language history boundaries with the real provider.useSourceEditing.lazyLoad.test.ts: real-engine cold multi-file edits, ordered caret/newline metadata and Reset followed by fresh edits.deferredSource.test.tsx: server-rendered input through the deferred loader, compact descriptors and exact CRLF windows.Verification: 6,503 unit tests and 106 browser tests pass; types, lint, release build, generated docs and packed modules pass. The two undo failures reproduced in the production integration and passed with the new package. Default renderer entry points exclude the editor vendor and parser engine.
Consumer integrations: material-ui#49910, mui-x#23851. Both final consumer deployments pass their source-editing and undo checks. Their PR descriptions contain 12-pair Lighthouse results: score changes are inconclusive, Material desktop TBT adds 3.5 ms, and X mobile TBT remains uncertain. The late input-replacement regression is resolved; no zero-cost claim is made.