Skip to content

fix(ilha): fix listed item morphing#68

Merged
yzuyr merged 1 commit into
mainfrom
fix/ilha-list-morphing
Jul 8, 2026
Merged

fix(ilha): fix listed item morphing#68
yzuyr merged 1 commit into
mainfrom
fix/ilha-list-morphing

Conversation

@yzuyr

@yzuyr yzuyr commented Jul 8, 2026

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • New Features

    • Keys in rendered output are now preserved as data-key attributes, improving list stability and component identity during reordering.
    • Form controls now keep checkbox and text input state in sync more reliably during updates.
  • Bug Fixes

    • Fixed list morphing issues where inserted siblings or duplicate keys could shift or replace the wrong elements.
    • Improved handling of user-entered input so typing and checked state are preserved when appropriate.
  • Chores

    • Updated package versions across the core library, router, store, and starter templates.

@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 32b81b56-55ac-4781-95d6-0e8cef5e3db8

📥 Commits

Reviewing files that changed from the base of the PR and between 4359298 and 4e9192d.

⛔ Files ignored due to path filters (1)
  • bun.lock is excluded by !**/*.lock
📒 Files selected for processing (12)
  • apps/website/package.json
  • packages/ilha/package.json
  • packages/ilha/src/index.test.ts
  • packages/ilha/src/index.ts
  • packages/ilha/src/jsx-runtime.test.tsx
  • packages/ilha/src/jsx-runtime.ts
  • packages/router/package.json
  • packages/store/package.json
  • templates/elysia/package.json
  • templates/hono/package.json
  • templates/nitro/package.json
  • templates/vite/package.json

📝 Walkthrough

Walkthrough

This PR reworks keyed DOM reconciliation and input property syncing in the ilha morph engine, adds data-key stamping to JSX-rendered output for keyed elements, adds corresponding test coverage, and bumps ilha/@ilha/router/@ilha/store versions across packages, apps, and templates.

Changes

Keyed Morph and JSX Data-Key Stamping

Layer / File(s) Summary
data-key stamping in JSX runtime
packages/ilha/src/jsx-runtime.ts
Adds escapeAttrValue/injectDataKey helpers; threads slotKey through renderJsxElement and jsx to stamp data-key onto rendered root elements for host and function components.
JSX runtime data-key tests
packages/ilha/src/jsx-runtime.test.tsx
Adds/updates tests verifying data-key emission, escaping, non-override of explicit data-key, and keyed identity preservation across reorders.
Keyed child reconciliation rewrite
packages/ilha/src/index.ts, packages/ilha/src/index.test.ts
Rewrites morphChildren keyed matching to compute toKey per position, consume matches from fromKeyed, and clone/insert when a node's key differs from the surviving key; adds regression tests for unkeyed siblings, text-node interpolation, and duplicate keys.
Input property sync during morph
packages/ilha/src/index.ts, packages/ilha/src/index.test.ts
Adds a dedicated input branch syncing live checked/value properties only when corresponding attributes changed, skipping generic children-morph; adds tests for checkbox and text-input sync behavior.

Estimated code review effort: 3 (Moderate) | ~30 minutes

Dependency Version Bumps

Layer / File(s) Summary
Version bumps across packages and templates
packages/ilha/package.json, packages/router/package.json, packages/store/package.json, apps/website/package.json, templates/elysia/package.json, templates/hono/package.json, templates/nitro/package.json, templates/vite/package.json
Bumps ilha to 0.9.2, @ilha/router to 0.8.4, @ilha/store to 0.7.2, and updates corresponding peer/dev dependency constraints throughout.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Sequence Diagram(s)

sequenceDiagram
  participant jsx
  participant renderJsxElement
  participant injectDataKey
  participant morphChildren
  participant fromKeyed

  jsx->>jsx: extract slotKey from props
  jsx->>renderJsxElement: render element with slotKey
  renderJsxElement->>injectDataKey: stamp data-key into root tag
  injectDataKey-->>renderJsxElement: RawHtml with data-key

  Note over morphChildren,fromKeyed: On next render/morph
  morphChildren->>morphChildren: compute toKey for each toNode
  morphChildren->>fromKeyed: lookup survivor by toKey
  fromKeyed-->>morphChildren: matched element (or none)
  alt current fromNode belongs to a different surviving key
    morphChildren->>morphChildren: clone and insert toNode
  else
    morphChildren->>morphChildren: move matched element into position
  end
Loading

Possibly related PRs

  • ilhajs/ilha#61: Both PRs modify packages/ilha/src/index.ts keyed reconciliation logic—this PR rewrites keyed morphChildren matching/moving using data-key, while the related PR addresses keyed slot replacement and teardown when slot ids are reused.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and matches the main change: fixing list item morphing behavior in ilha.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/ilha-list-morphing

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@yzuyr
yzuyr merged commit 78e137a into main Jul 8, 2026
5 checks passed
@yzuyr
yzuyr deleted the fix/ilha-list-morphing branch July 8, 2026 12:58
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.

1 participant