Repository navigation
Conversation
|
The corrected head The first browser run exposed two real gaps: a parent Redo's restored root selection could blur and commit an unrelated pending cell, and cleared cell-local history could bubble availability events into the root toolbar. The correction preserves surviving nested focus/caret during native history restoration, suppresses only the restoration-induced blur, and accepts toolbar availability only from the active editor or its actual shared history. It does not reroute Undo/Redo or change history stacks. Existing assertions were retained; the sibling test now also checks final Redo focus/caret. Final local verification: 271 unit tests passed (existing 1 skip/1 todo retained), full lint, typecheck, library/declaration build, and the 24-package Lexical graph check. Independent corrective review reran 67 focused tests successfully. The published tree was fetched and matched the tested tree exactly. This remains a separate draft core repair; no merge or deployment was performed. |
petyosi
left a comment
There was a problem hiding this comment.
Thanks for splitting this out. The table-cell bug is real. On main, if you edit a cell, blur it and press Undo in the root, the markdown goes back but the cell still shows the edit. But this PR fixes three separate problems at once, and it changes history behaviour for every nested editor. I'd like it reduced to the table-cell fix.
What's in here:
- (a) Stale cell after a parent Undo (
TableEditor.tsx:475-519). An effect re-imports the cell when its stored contents change, andsave()refuses stale writes. This is the part I asked for, and it is small and reasonable. - (b) Nested-editor saves no longer create root history steps (
NestedLexicalEditor.tsx:122-150, 310-375,lexicalExtensions.ts:149-157, 278-325). This applies to every directive and JSX editor. It caused the browser regressions fixed in dd014f8. That fix adds high-priority UNDO/REDO handlers on every editor with history, which restore focus and the DOM range in asetTimeout, plus blur suppression during restores and per-editor filtering of CAN_UNDO/CAN_REDO inUndoRedo.tsx. That is a lot of global machinery, and every piece of it is a new way for focus and selection to go wrong. - (c) A history baseline for the first edit (
ensureEditorHistoryBaseline). It forces an entry with a no-opmarkDirty(), canJSON.stringifythe whole editor state, and runs on every cell save and property update.
Other problems:
useMdastNodeUpdaternow callsgetMdastNode()unconditionally (NestedLexicalEditor.tsx:133-142). The publicNestedEditorsContextValue.lexicalNodecontract only requiressetMdastNode(), so a custom node that met the contract now throwsgetMdastNode is not a function.undo-redo.test.tsx:254changes the 1d7fa34 assertion fromeditedDepth + 1toeditedDepth. That is a deliberate change to how deep the history is, and it belongs with (b), not with the table fix.
A minimal version of (a) is about 40 lines in TableEditor.tsx:
- an effect keyed on a persisted-contents ref, so uncommitted typing in other cells is not overwritten;
- a re-import tagged with
HISTORIC_TAG; - clearing the cell's local history after the re-import;
- the stale-content check in
save().
With that, the existing suite and your root-table Undo/Redo, sibling-typing and stale-blur cases pass. If you think (b) or (c) are worth fixing, please open issues with repros first, so we can agree on an approach before more code.
Integrate current main while removing global nested history, focus restoration, and first-edit baseline changes. Retain only table persisted-content import, local history clearing and stale-save protection, with root-table regressions. Restore original nested editor contract and existing Undo history assertions. 308 unit tests and complete typecheck pass; changed-file typed lint passes. Three root-table regressions fail on the old baseline and pass with the fix. Native browser and complete declaration build await exact-head CI; local browser restrictions were not bypassed and declaration rollup was resource-killed.
|
Addressed the requested reduction in
Exact-head CI for b6377fb is now successful in all four jobs, with 156/156 browser tests (52 each Chromium, Firefox, WebKit). Local follow-on checks: 12 focused tests, full typecheck and changed-file typed lint passed. The published files were read back and matched the tested candidate. This remains draft for review; no upstream merge was performed. |
After #1004 was narrowed to table cells, the nested-history names and the single-item loop in the browser spec no longer described what they cover.
|
Merged, thanks. This is the size I asked for. The effect only re-imports a cell when its stored contents change. The stale-write check in On top of it, 07daea0 renames the example and tests from The temporary CAN_UNDO/CAN_REDO handlers around |
|
🎉 This PR is included in version 4.5.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Scope
Separate core Undo/export/reconciliation repair requested in the review of #996. No table-region paste feature, spreadsheet UI, history-command routing, public API, or dependency changes are included here.
Changes
Regression evidence
On freshly fetched main
e186ded343e87a790deeabfb253531099d82a9fb, ordinary edit → blur → Undo failed in root, real directive, real JSX, and multi-level nesting: root Markdown reverted while mounted cells stayed stale; nested exports also added history steps.The new 28-case suite covers those paths, first-cell edits, root-origin restores, repeated edit/focus cycles, exact parent Undo counts, Redo after focus changes, stale blur, unsaved siblings, local history after authoritative replacement, and explicit JSX properties. Five new browser scenarios cover native typing, root keyboard Undo/Redo, repeated cycles, and unaffected-cell focus/caret/history across Chromium, Firefox, and WebKit.
Verification
Head:
9d56758d34382ea9f42cdbabad0a29eaa9139efd(published tree exactly matches the locally tested tree).Passed locally:
Draft: exact-head CI browser/package/cross-version validation is pending. Local browser startup was blocked by the cloud sandbox before any page opened; this is not a browser pass. An initial resource-killed build was rerun successfully with a bounded Node heap. This PR is not marked ready for review pending the remaining CI gates.