Skip to content

fix(draw): normalize swimlane cell order - #1157

Merged
pubuzhixing8 merged 4 commits into
developfrom
codex/normalize-table-cells-order
Jul 23, 2026
Merged

fix(draw): normalize swimlane cell order#1157
pubuzhixing8 merged 4 commits into
developfrom
codex/normalize-table-cells-order

Conversation

@pubuzhixing8

Copy link
Copy Markdown
Collaborator

No description provided.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 20, 2026

Copy link
Copy Markdown

Deploying plait with  Cloudflare Pages  Cloudflare Pages

Latest commit: d067c46
Status: ✅  Deploy successful!
Preview URL: https://b50137a0.plait.pages.dev
Branch Preview URL: https://codex-normalize-table-cells.plait.pages.dev

View logs

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 20, 2026

Copy link
Copy Markdown

Deploying plait-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: d067c46
Status: ✅  Deploy successful!
Preview URL: https://8f23336e.plait-docs.pages.dev
Branch Preview URL: https://codex-normalize-table-cells.plait-docs.pages.dev

View logs

@pubuzhixing8

pubuzhixing8 commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator Author

Here is some additional context to make this PR easier to review.

Root cause

When a row or column is inserted in the middle of a swimlane, the newly created cells are appended to the end of the cells array. As a result, the cell order may no longer match the current rows and columns order.

Changes

  • Added normalizeTableCellsOrder to sort cells in row-major order based on their indices in rows and columns: top to bottom, then left to right within each row.
  • Normalize the cell order before updateSwimlane writes the updated data, covering swimlane row and column mutations.
  • Moved the sorting logic into a dependency-free utility module to prevent the unit test from loading the complete table utility dependency chain and triggering a circular dependency.

Test coverage

The tests now cover the actual swimlane transform behavior:

  • Insert a row in the middle of a horizontal swimlane and verify the final cell order.
  • Insert a column in the middle of a vertical swimlane and verify the final cell order.
  • Keep the basic test for sorting an unordered cell array.
  • Removed the malformed-data case because it is outside the scope of this PR.

Local targeted tests: TOTAL: 3 SUCCESS. build:draw also passes.

The main review points are whether normalization happens at the correct stage in updateSwimlane, and whether row-major order is the expected order after inserting rows or columns.

@nightt5879 nightt5879 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Could you add a changeset for this fix?

Comment thread packages/draw/src/transforms/swimlane.ts
@pubuzhixing8
pubuzhixing8 merged commit ec7593d into develop Jul 23, 2026
3 checks passed
@pubuzhixing8
pubuzhixing8 deleted the codex/normalize-table-cells-order branch July 23, 2026 01:40
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