Skip to content

fix(web): when a list-item is deleted from list, the deleted list-ite…#1092

Merged
Sherry-hue merged 1 commit intolynx-family:mainfrom
Sherry-hue:fix/list-item-remove
Jan 22, 2026
Merged

fix(web): when a list-item is deleted from list, the deleted list-ite…#1092
Sherry-hue merged 1 commit intolynx-family:mainfrom
Sherry-hue:fix/list-item-remove

Conversation

@Sherry-hue
Copy link
Copy Markdown
Collaborator

@Sherry-hue Sherry-hue commented Jun 17, 2025

…m is still showed incorrectly

Summary

fix: when a list-item is deleted from list, the deleted list-item is still showed incorrectly.

This is because the enqueueComponent method does not delete the node from the Element Tree. It is only to maintain all nodes on the RL side, and lynx web needs to delete the dom additionally.

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

Summary by CodeRabbit

  • Bug Fixes

    • Deleted list items no longer remain visible — UI now properly removes items from the DOM and display.
  • Tests

    • Expanded update-list tests (insert/remove/mixed/randomized) and added a new visual test to verify list removal toggles and states.
  • Style

    • Added stylesheet for the new list removal test page to ensure consistent layout.
  • Notes

    • No public API signatures were changed.

✏️ Tip: You can customize this high-level summary in your review settings.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Jun 17, 2025

🦋 Changeset detected

Latest commit: 07a424a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 11 packages
Name Type
@lynx-js/web-mainthread-apis Patch
@lynx-js/web-worker-rpc Patch
@lynx-js/web-constants Patch
@lynx-js/web-core-server Patch
@lynx-js/web-core Patch
@lynx-js/web-worker-runtime Patch
@lynx-js/web-core-wasm Patch
upgrade-rspeedy Patch
@lynx-js/web-rsbuild-server-middleware Patch
@lynx-js/rspeedy Patch
create-rspeedy Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@Sherry-hue Sherry-hue requested a review from hzy June 17, 2025 09:39
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Jun 17, 2025

CodSpeed Performance Report

Merging this PR will improve performance by 7.81%

Comparing Sherry-hue:fix/list-item-remove (07a424a) with main (5b589ab)

Summary

⚡ 2 improved benchmarks
✅ 61 untouched benchmarks
⏩ 3 skipped benchmarks1

Performance Changes

Benchmark BASE HEAD Efficiency
transform 1000 view elements 46.8 ms 43.7 ms +6.97%
basic-performance-nest-level-100 7.4 ms 6.9 ms +7.81%

Footnotes

  1. 3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@hzy
Copy link
Copy Markdown
Collaborator

hzy commented Jun 17, 2025

Good job! But the test feels a bit naive... A stress test like rendering a randomly shuffled array can help make sure your implementation correct.

function shuffleArray(array) {
    for (let i = array.length - 1; i >= 1; i--) {
        const j = Math.floor(Math.random() * (i + 1));
        [array[i], array[j]] = [array[j], array[i]];
    }
}

@relativeci
Copy link
Copy Markdown

relativeci Bot commented Jun 17, 2025

Web Explorer

#7302 Bundle Size — 383.96KiB (+0.05%).

07a424a(current) vs 5b589ab main#7300(baseline)

Bundle metrics  Change 3 changes
                 Current
#7302
     Baseline
#7300
No change  Initial JS 154.12KiB 154.12KiB
No change  Initial CSS 35.05KiB 35.05KiB
Change  Cache Invalidation 7.45% 0%
No change  Chunks 8 8
No change  Assets 8 8
Change  Modules 236(-0.84%) 238
No change  Duplicate Modules 16 16
Change  Duplicate Code 2.99%(-0.33%) 3%
No change  Packages 4 4
No change  Duplicate Packages 0 0
Bundle size by type  Change 1 change Regression 1 regression
                 Current
#7302
     Baseline
#7300
Regression  JS 251.89KiB (+0.07%) 251.71KiB
No change  Other 97.02KiB 97.02KiB
No change  CSS 35.05KiB 35.05KiB

Bundle analysis reportBranch Sherry-hue:fix/list-item-removeProject dashboard


Generated by RelativeCIDocumentationReport issue

@relativeci
Copy link
Copy Markdown

relativeci Bot commented Jun 17, 2025

React Example

#1733 Bundle Size — 232.61KiB (0%).

04dc052(current) vs e10c9fc main#1725(baseline)

Bundle metrics  no changes
                 Current
#1733
     Baseline
#1725
No change  Initial JS 0B 0B
No change  Initial CSS 0B 0B
No change  Cache Invalidation 0% 0%
No change  Chunks 0 0
No change  Assets 4 4
No change  Modules 143 143
No change  Duplicate Modules 55 55
No change  Duplicate Code 45.68% 45.68%
No change  Packages 2 2
No change  Duplicate Packages 0 0
Bundle size by type  no changes
                 Current
#1733
     Baseline
#1725
No change  IMG 145.76KiB 145.76KiB
No change  Other 86.86KiB 86.86KiB

Bundle analysis reportBranch Sherry-hue:fix/list-item-removeProject dashboard


Generated by RelativeCIDocumentationReport issue

@Sherry-hue Sherry-hue force-pushed the fix/list-item-remove branch 2 times, most recently from a7ba37e to 04dc052 Compare June 18, 2025 08:13
@Sherry-hue Sherry-hue assigned PupilTong and unassigned Sherry-hue Jun 18, 2025
@github-actions
Copy link
Copy Markdown
Contributor

This pull request has been automatically marked as stale because it has not had recent activity. If this pull request is still relevant, please leave any comment (for example, "bump").

@github-actions github-actions Bot added the stale Inactive for 30 days. Will be closed by bots. label Aug 19, 2025
@Sherry-hue Sherry-hue force-pushed the fix/list-item-remove branch from 04dc052 to 106639b Compare January 21, 2026 13:03
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 21, 2026

📝 Walkthrough

Walkthrough

Fixes list-item deletion visibility by changing the removeAction payload shape and updating main-thread update logic to remove DOM nodes before insertions; adds unit and E2E tests and a changeset patching three packages. (50 words)

Changes

Cohort / File(s) Summary
Type Definition Update
packages/web-platform/web-constants/src/types/MainThreadGlobalThis.ts
UpdateListInfoAttributeValue.removeAction changed from { position: number }[] to number[].
Core Logic Implementation
packages/web-platform/web-mainthread-apis/ts/createMainThreadGlobalThis.ts
Removal handled pre-insertion: enqueue removal signs and remove corresponding DOM nodes before inserts; insertion loop adjusted to move existing elements into new positions with safety checks.
Unit Tests
packages/web-platform/web-tests/tests/main-thread-apis.test.ts
Expanded update-list-info tests by adding a second set of insert/remove/mixed/stress scenarios (duplicates existing test blocks).
E2E Test & Assets
packages/web-platform/web-tests/tests/react.spec.ts, packages/web-platform/web-tests/tests/react/basic-element-list-remove-action/index.jsx, packages/web-platform/web-tests/tests/react/basic-element-list-remove-action/index.css
New E2E test basic-element-list-remove-action plus test page and styles verifying list remove/restore transitions.
Changeset Metadata
.changeset/cuddly-roses-start.md
New changeset describing patch releases for @lynx-js/web-mainthread-apis, @lynx-js/web-worker-rpc, and @lynx-js/web-constants.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • hzy

Poem

🐇 I nudged a ghost node off the floor,
Hopped through DOM holes and closed the door,
Queued a sign, then pulled a thread,
Moved the pieces, cleared the spread,
Tests turned green — I thumped in glee.

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title is truncated and incomplete, ending with 'the deleted list-ite…' which makes it vague and hard to understand the full scope of the fix. Complete the title to clearly state the fix, such as: 'fix(web): remove deleted list-items from DOM' or similar concise statement.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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 and usage tips.

@codecov
Copy link
Copy Markdown

codecov Bot commented Jan 21, 2026

Codecov Report

❌ Patch coverage is 0% with 19 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...b-mainthread-apis/ts/createMainThreadGlobalThis.ts 0.00% 19 Missing ⚠️

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In @.changeset/cuddly-roses-start.md:
- Around line 7-9: Update the release-note text to improve grammar and clarity:
rephrase the entry about deleted list-items so it reads something like "Fix:
when a list-item is deleted, it could still be shown because enqueueComponent
does not remove the node from the Element Tree; enqueueComponent only maintains
the display node on RL, so lynx web must explicitly delete the DOM node." Ensure
you reference the terms enqueueComponent, Element Tree, RL, and lynx web exactly
as in the note and replace the current two-sentence fragment with this single
clear sentence.
🧹 Nitpick comments (3)
packages/web-platform/web-tests/tests/react/basic-element-list-remove-action/index.css (1)

18-23: Add border-style so the list-item border actually renders.

Without a border style, browsers treat the border as none, so the green border won’t show. Consider adding border-style: solid for clarity in screenshot-based tests.

[select_commentary]

♻️ Suggested change
list-item {
  border-width: 5px;
+ border-style: solid;
  border-color: green;
  width: 100%;
  height: 100px;
  background-color: yellow;
}
packages/web-platform/web-tests/tests/main-thread-apis.test.ts (1)

1399-1550: Consider a deterministic shuffle stress test for list mutations.

The three tests cover core flows, but a shuffled sequence of insert/remove positions would better exercise edge ordering. To avoid flakiness, keep the shuffle deterministic (seeded or fixed permutations).

🧪 Example deterministic shuffle helper
const makeRng = (seed = 123456789) => () => {
  seed = (1664525 * seed + 1013904223) >>> 0;
  return seed / 2 ** 32;
};

const shuffleArray = <T,>(arr: T[], rng = makeRng()) => {
  for (let i = arr.length - 1; i > 0; i--) {
    const j = Math.floor(rng() * (i + 1));
    [arr[i], arr[j]] = [arr[j], arr[i]];
  }
  return arr;
};
packages/web-platform/web-tests/tests/react.spec.ts (1)

4647-4660: Consider adding a stress test with shuffled array rendering.

The test covers basic sequential removal scenarios, which validates the fix. Per reviewer feedback, consider adding an additional test case that renders a randomly shuffled array to more rigorously validate the removal logic under varied ordering conditions.

The suggested shuffleArray function from the review comments:

function shuffleArray(array) {
    for (let i = array.length - 1; i >= 1; i--) {
        const j = Math.floor(Math.random() * (i + 1));
        [array[i], array[j]] = [array[j], array[i]];
    }
}

Comment thread .changeset/cuddly-roses-start.md
@Sherry-hue Sherry-hue force-pushed the fix/list-item-remove branch from 106639b to ac8e7f4 Compare January 21, 2026 13:16
PupilTong
PupilTong previously approved these changes Jan 21, 2026
@Sherry-hue Sherry-hue force-pushed the fix/list-item-remove branch 3 times, most recently from 7ec6952 to 0f0f17a Compare January 22, 2026 06:15
@Sherry-hue Sherry-hue force-pushed the fix/list-item-remove branch from 0f0f17a to 07a424a Compare January 22, 2026 11:56
@Sherry-hue Sherry-hue merged commit f7133c1 into lynx-family:main Jan 22, 2026
74 of 78 checks passed
colinaaa pushed a commit that referenced this pull request Jan 25, 2026
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @lynx-js/react@0.116.0

### Minor Changes

- **BREAKING CHANGE**: Bump Preact from
[10.24.0](preactjs/preact@1807173)
to
[10.28.0](preactjs/preact@f7693b7),
see diffs at [hzy/preact#6](hzy/preact#6).
([#2042](#2042))

### Patch Changes

- Add safety checks for compilation macros to prevent runtime errors
when they are undefined.
([#2110](#2110))

Replaces direct usage of `__PROFILE__`, `__MAIN_THREAD__`,
`__BACKGROUND__` with `typeof` checks.

This improves robustness by checking variable existence before access,
preventing runtime errors in environments where compilation macros are
not defined.

## @lynx-js/lynx-bundle-rslib-config@0.2.0

### Minor Changes

- Use `LAYERS` exposed by DSL plugins
([#2114](#2114))

## @lynx-js/gesture-runtime@2.1.2

### Patch Changes

- Fix an issue that `NativeGesture` does not get correct types in
callback ([#2130](#2130))

## @lynx-js/rspeedy@0.13.1

### Patch Changes

-   Updated dependencies \[]:
    -   @lynx-js/web-rsbuild-server-middleware@0.19.6

## @lynx-js/react-rsbuild-plugin@0.12.6

### Patch Changes

- Support using `pluginReactLynx` in Rslib.
([#2114](#2114))

- Updated dependencies
\[[`4cd7182`](4cd7182)]:
    -   @lynx-js/template-webpack-plugin@0.10.2
    -   @lynx-js/react-alias-rsbuild-plugin@0.12.6
    -   @lynx-js/use-sync-external-store@1.5.0
    -   @lynx-js/react-refresh-webpack-plugin@0.3.4
    -   @lynx-js/react-webpack-plugin@0.7.3
    -   @lynx-js/css-extract-webpack-plugin@0.7.0

## upgrade-rspeedy@0.13.1

### Patch Changes

- Fix the issue `rslib-runtime.js` was not published in dist folder.
([#2122](#2122))

## @lynx-js/testing-environment@0.1.10

### Patch Changes

- Fix the error "lynxTestingEnv is not defined"
([#2118](#2118))

## @lynx-js/web-constants@0.19.6

### Patch Changes

- feat: add main-thread API: \_\_QuerySelector
([#2115](#2115))

- fix: when a list-item is deleted from list, the deleted list-item is
still showed incorrectly.
([#1092](#1092))

This is because the `enqueueComponent` method does not delete the node
from the Element Tree. It is only to maintain the display node on RL,
and lynx web needs to delete the dom additionally.

- feat: support main thread invoke ui method
([#2104](#2104))

- feat: support lynx.reload()
([#2127](#2127))

- Updated dependencies
\[[`f7133c1`](f7133c1)]:
    -   @lynx-js/web-worker-rpc@0.19.6

## @lynx-js/web-core@0.19.6

### Patch Changes

- fix: avoid crash on CPUs that do not support SIMD
([#2133](#2133))

- feat: support lynx.reload()
([#2127](#2127))

- Updated dependencies
\[[`179f984`](179f984),
[`f7133c1`](f7133c1),
[`6c2b51a`](6c2b51a),
[`556fe9f`](556fe9f),
[`5b589ab`](5b589ab)]:
    -   @lynx-js/web-constants@0.19.6
    -   @lynx-js/web-mainthread-apis@0.19.6
    -   @lynx-js/web-worker-rpc@0.19.6
    -   @lynx-js/web-worker-runtime@0.19.6

## @lynx-js/web-core-wasm@0.0.1

### Patch Changes

- Updated dependencies
\[[`f7133c1`](f7133c1)]:
    -   @lynx-js/web-worker-rpc@0.19.6

## @lynx-js/web-mainthread-apis@0.19.6

### Patch Changes

- feat: add main-thread API: \_\_QuerySelector
([#2115](#2115))

- fix: when a list-item is deleted from list, the deleted list-item is
still showed incorrectly.
([#1092](#1092))

This is because the `enqueueComponent` method does not delete the node
from the Element Tree. It is only to maintain the display node on RL,
and lynx web needs to delete the dom additionally.

- feat: support main thread invoke ui method
([#2104](#2104))

- fix: mts && bts events can be binded both
([#2121](#2121))

- Updated dependencies
\[[`179f984`](179f984),
[`f7133c1`](f7133c1),
[`6c2b51a`](6c2b51a),
[`5b589ab`](5b589ab)]:
    -   @lynx-js/web-constants@0.19.6

## @lynx-js/web-worker-rpc@0.19.6

### Patch Changes

- fix: when a list-item is deleted from list, the deleted list-item is
still showed incorrectly.
([#1092](#1092))

This is because the `enqueueComponent` method does not delete the node
from the Element Tree. It is only to maintain the display node on RL,
and lynx web needs to delete the dom additionally.

## @lynx-js/web-worker-runtime@0.19.6

### Patch Changes

- feat: support lynx.reload()
([#2127](#2127))

- Updated dependencies
\[[`179f984`](179f984),
[`f7133c1`](f7133c1),
[`6c2b51a`](6c2b51a),
[`556fe9f`](556fe9f),
[`5b589ab`](5b589ab)]:
    -   @lynx-js/web-constants@0.19.6
    -   @lynx-js/web-mainthread-apis@0.19.6
    -   @lynx-js/web-worker-rpc@0.19.6

## @lynx-js/template-webpack-plugin@0.10.2

### Patch Changes

- Polyfill `lynx.requireModuleAsync` to allow cache same parallel
requests. ([#2108](#2108))

## create-rspeedy@0.13.1



## @lynx-js/react-alias-rsbuild-plugin@0.12.6



## @lynx-js/web-core-server@0.19.6



## @lynx-js/web-rsbuild-server-middleware@0.19.6

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

platform:Web stale Inactive for 30 days. Will be closed by bots.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants