Skip to content

Conversation

@Sherry-hue
Copy link
Collaborator

@Sherry-hue Sherry-hue commented Jul 14, 2025

fix: list may only render only one column in ReactLynx.

This is because span-count may not be specified when list-type is specified, resulting in layout according to span-count="1". Postponing the acquisition of span-count until layoutListItem can solve this problem.

Summary

Checklist

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

Summary by CodeRabbit

  • Bug Fixes

    • Resolved an issue where lists could display only one column even when a multi-column layout was specified.
  • Tests

    • Added a new test to verify the correct rendering of a basic element list in a waterfall layout.
  • Style

    • Introduced new CSS styles for the basic element list waterfall layout, ensuring visually distinct items and improved layout appearance.
  • New Features

    • Added a new example component demonstrating a two-column waterfall-style list with dynamic item heights.

@changeset-bot
Copy link

changeset-bot bot commented Jul 14, 2025

🦋 Changeset detected

Latest commit: d1f296c

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

This PR includes changesets to release 2 packages
Name Type
@lynx-js/web-elements Patch
@lynx-js/web-elements-template 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 force-pushed the fix/rl-list-waterfall branch from 7d68639 to d1f296c Compare July 14, 2025 07:13
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 14, 2025

Walkthrough

The changes update the ReactLynx list component to fix column rendering by centralizing attribute reading for layout configuration in private methods. A new test, corresponding CSS, and a React demo component are added to verify and showcase a basic waterfall list layout with distinct item heights and colors.

Changes

File(s) Change Summary
.changeset/early-drinks-stay.md Documents the fix for column rendering in the ReactLynx list component.
packages/web-platform/web-elements/src/XList/XListWaterfall.ts Refactors private methods to retrieve layout attributes internally; updates method signatures and call sites.
packages/web-platform/web-tests/tests/react.spec.ts Adds a new test case for the basic element list waterfall scenario.
packages/web-platform/web-tests/tests/react/basic-element-list-waterfall/index.css Introduces CSS for the waterfall list demo, including dynamic coloring and layout constraints.
packages/web-platform/web-tests/tests/react/basic-element-list-waterfall/index.jsx Adds a new React component demonstrating a two-column waterfall list with variable item heights and colors.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant App (React)
    participant XList (Web Component)
    participant DOM

    User->>App (React): Loads page
    App (React)->>XList: Renders <list list-type="waterfall" span-count="2">
    XList->>DOM: Reads span-count, list-type attributes
    XList->>XList: #layoutListItem() (retrieves attributes internally)
    XList->>DOM: Lays out items in two columns, variable heights
Loading

Poem

🐇
A waterfall list, now flowing true,
With columns counted—one, then two!
Colors dance, heights rise and fall,
Each item stands proud, unique and tall.
With tests and styles, the bugs are gone—
The rabbit hops, the code moves on!
🌈

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

 ERROR  Cannot resolve version $@rspack/core in overrides. The direct dependencies don't have dependency "@rspack/core".
For help, run: pnpm help install

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
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

🧹 Nitpick comments (3)
packages/web-platform/web-elements/src/XList/XListWaterfall.ts (1)

187-199: Consider caching attribute values for performance.

While the refactoring correctly addresses the timing issue, repeatedly reading DOM attributes in the resize observer callback could impact performance during frequent resize events.

Consider caching the attribute values or debouncing the resize callback:

 #resizeObserverInit = () => {
   this.#resizeObserver?.disconnect();
   this.#resizeObserver = new ResizeObserver(() => {
     // may cause: Resizeobserver loop completed with undelivered notifications
     // https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver#observation_errors
     requestAnimationFrame(() => {
       this.#layoutListItem();
     });
   });
   Array.from(this.#dom.children).forEach(element => {
     this.#resizeObserver?.observe(element);
   });
 };

Alternatively, implement a debounced version of the resize callback to reduce the frequency of attribute reads during rapid resize events.

.changeset/early-drinks-stay.md (1)

5-5: Fix redundant word usage in description.

The description contains redundant use of "only" which affects readability.

Apply this diff to fix the redundant word:

-fix: list may only render only one column in ReactLynx.
+fix: list may only render one column in ReactLynx.
packages/web-platform/web-tests/tests/react/basic-element-list-waterfall/index.jsx (1)

4-4: Remove unused imports.

The component imports useRef, useState, and useEffect but doesn't use them. Consider removing these unused imports to clean up the code.

-import { root, useRef, useState, useEffect } from '@lynx-js/react';
+import { root } from '@lynx-js/react';
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d938579 and d1f296c.

⛔ Files ignored due to path filters (3)
  • packages/web-platform/web-tests/tests/react.spec.ts-snapshots/list/basic-element-list-waterfall/initial-chromium-linux.png is excluded by !**/*.png
  • packages/web-platform/web-tests/tests/react.spec.ts-snapshots/list/basic-element-list-waterfall/initial-firefox-linux.png is excluded by !**/*.png
  • packages/web-platform/web-tests/tests/react.spec.ts-snapshots/list/basic-element-list-waterfall/initial-webkit-linux.png is excluded by !**/*.png
📒 Files selected for processing (5)
  • .changeset/early-drinks-stay.md (1 hunks)
  • packages/web-platform/web-elements/src/XList/XListWaterfall.ts (4 hunks)
  • packages/web-platform/web-tests/tests/react.spec.ts (1 hunks)
  • packages/web-platform/web-tests/tests/react/basic-element-list-waterfall/index.css (1 hunks)
  • packages/web-platform/web-tests/tests/react/basic-element-list-waterfall/index.jsx (1 hunks)
🧰 Additional context used
🪛 LanguageTool
.changeset/early-drinks-stay.md

[style] ~5-~5: This adverb was used twice in the sentence. Consider removing one of them or replacing them with a synonym.
Context: ...": patch --- fix: list may only render only one column in ReactLynx. This is becau...

(ADVERB_REPETITION_PREMIUM)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: CodeQL Analyze (actions)
🔇 Additional comments (5)
packages/web-platform/web-elements/src/XList/XListWaterfall.ts (2)

38-45: LGTM! Good refactoring to fix timing issue.

The change to retrieve spanCount and isScrollVertical from DOM attributes internally addresses the core issue where span-count might not be available when list-type is initially set. This ensures the correct column count is used during layout phase.


193-193: LGTM! Method calls correctly updated.

All method calls have been properly updated to match the new parameter-less signatures.

Also applies to: 207-207, 216-216

.changeset/early-drinks-stay.md (1)

7-7: LGTM! Accurate technical explanation.

The description correctly explains the root cause and solution for the column rendering issue.

packages/web-platform/web-tests/tests/react/basic-element-list-waterfall/index.css (1)

1-23: LGTM! Well-structured CSS for waterfall list testing.

The CSS effectively supports the waterfall list test with:

  • Proper container setup with flex layout
  • Fixed dimensions for consistent test results
  • Creative use of CSS custom properties for dynamic item styling

The hsl(calc(15 * var(--item-index)), 100%, 50%) approach provides good visual differentiation between items.

packages/web-platform/web-tests/tests/react/basic-element-list-waterfall/index.jsx (1)

29-43: Excellent test implementation for waterfall list functionality.

The component effectively demonstrates the waterfall list with:

  • Proper use of span-count='2' which aligns with the PR fix
  • Varied item heights from the data array for realistic waterfall testing
  • Consistent styling approach using CSS custom properties
  • Clean component structure for testing purposes

This test case will help verify that the span-count attribute is correctly applied during the layout phase.

@codecov
Copy link

codecov bot commented Jul 14, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@codspeed-hq
Copy link

codspeed-hq bot commented Jul 14, 2025

CodSpeed Performance Report

Merging #1280 will not alter performance

Comparing Sherry-hue:fix/rl-list-waterfall (d1f296c) with main (d938579)

Summary

✅ 10 untouched benchmarks

@relativeci
Copy link

relativeci bot commented Jul 14, 2025

React Example

#2897 Bundle Size — 234.12KiB (0%).

d1f296c(current) vs d938579 main#2889(baseline)

Bundle metrics  no changes
                 Current
#2897
     Baseline
#2889
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 153 153
No change  Duplicate Modules 61 61
No change  Duplicate Code 45.85% 45.85%
No change  Packages 2 2
No change  Duplicate Packages 0 0
Bundle size by type  no changes
                 Current
#2897
     Baseline
#2889
No change  IMG 145.76KiB 145.76KiB
No change  Other 88.37KiB 88.37KiB

Bundle analysis reportBranch Sherry-hue:fix/rl-list-waterfallProject dashboard


Generated by RelativeCIDocumentationReport issue

@relativeci
Copy link

relativeci bot commented Jul 14, 2025

Web Explorer

#2888 Bundle Size — 303.03KiB (~-0.01%).

d1f296c(current) vs d938579 main#2880(baseline)

Bundle metrics  Change 3 changes Improvement 1 improvement
                 Current
#2888
     Baseline
#2880
Improvement  Initial JS 139.83KiB(-0.02%) 139.86KiB
No change  Initial CSS 31.88KiB 31.88KiB
Change  Cache Invalidation 46.15% 0%
No change  Chunks 4 4
No change  Assets 5 5
Change  Modules 205(+0.49%) 204
No change  Duplicate Modules 17 17
No change  Duplicate Code 4.21% 4.21%
No change  Packages 3 3
No change  Duplicate Packages 0 0
Bundle size by type  Change 1 change Improvement 1 improvement
                 Current
#2888
     Baseline
#2880
Improvement  JS 220.26KiB (-0.01%) 220.29KiB
No change  Other 50.89KiB 50.89KiB
No change  CSS 31.88KiB 31.88KiB

Bundle analysis reportBranch Sherry-hue:fix/rl-list-waterfallProject dashboard


Generated by RelativeCIDocumentationReport issue

@Sherry-hue Sherry-hue added this pull request to the merge queue Jul 14, 2025
Merged via the queue into lynx-family:main with commit b70386f Jul 14, 2025
65 of 67 checks passed
@Sherry-hue Sherry-hue deleted the fix/rl-list-waterfall branch July 14, 2025 08:22
colinaaa pushed a commit that referenced this pull request Jul 19, 2025
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/[email protected]

### Patch Changes

- Optimize `componentAtIndex` by a few hundreds microseconds: avoiding
manipulate `__pendingListUpdates` unless SnapshotInstance tree is
changed ([#1201](#1201))

- Support alog of component rendering on production for better error
reporting. Enable it by using `REACT_ALOG=true rspeedy dev/build` or
defining `__ALOG__` to `true` in `lynx.config.js`:
([#1164](#1164))

    ```js
    export default defineConfig({
      // ...
      source: {
        define: {
          __ALOG__: true,
        },
      },
    });
    ```

- Make `preact/debug` work with `@lynx-js/react`.
([#1222](#1222))

- Introduce `@lynx-js/react/debug` which would include debugging
warnings and error messages for common mistakes found.
([#1250](#1250))

Add the import to `@lynx-js/react/debug` at the first line of the entry:

    ```js
    import "@lynx-js/react/debug";
    import { root } from "@lynx-js/react";

    import { App } from "./App.jsx";

    root.render(<App />);
    ```

- `<list-item/>` deferred now accepts an object with `unmountRecycled`
property to control unmounting behavior when the item is recycled.
([#1302](#1302))

    For example, you can use it like this:

    ```jsx
    <list-item defer={{ unmountRecycled: true }} item-key="1">
      <WillBeUnmountIfRecycled />
    </list-item>
    ```

Now the component will be unmounted when it is recycled, which can help
with performance in certain scenarios.

- Avoid some unexpected `__SetAttribute` in hydrate when `undefined` is
passed as an attribute value to intrinsic elements, for example:
([#1318](#1318))

    ```jsx
    <image async-mode={undefined} />
    ```

## @lynx-js/[email protected]

### Patch Changes

- Bump Rsbuild v1.4.6 with Rspack v1.4.8.
([#1282](#1282))

## [email protected]

### Patch Changes

- Add `import '@lynx-js/react/debug'` for all templates.
([#1250](#1250))

## @lynx-js/[email protected]

### Patch Changes

- Fix "TypeError: cannot read property 'call' of undefined" error during
HMR updates.
([#1304](#1304))

- Supports extractStr for large JSON
([#1230](#1230))

- Change `extractStr` to `false` when `performance.chunkSplit.strategy`
is not `all-in-one`.
([#1251](#1251))

- Updated dependencies
\[[`cb7feb6`](cb7feb6),
[`ec7228f`](ec7228f)]:
    -   @lynx-js/[email protected]
    -   @lynx-js/[email protected]
    -   @lynx-js/[email protected]
    -   @lynx-js/[email protected]
    -   @lynx-js/[email protected]
    -   @lynx-js/[email protected]

## @lynx-js/[email protected]

### Patch Changes

- Support `@lynx-js/react/debug`.
([#1250](#1250))

## @lynx-js/[email protected]

### Patch Changes

- Support alog of component rendering on production for better error
reporting. Enable it by using `REACT_ALOG=true rspeedy dev/build` or
defining `__ALOG__` to `true` in `lynx.config.js`:
([#1164](#1164))

    ```js
    export default defineConfig({
      // ...
      source: {
        define: {
          __ALOG__: true,
        },
      },
    });
    ```

- Supports `console.alog` and use different `console` object in main
thread and background thread.
([#1164](#1164))

## @lynx-js/[email protected]

### Patch Changes

- feat: move SSR hydrate essential info to the ssr attribute
([#1292](#1292))

We found that in browser there is no simple tool to decode a base64
string

    Therefore we move the data to `ssr` attribute

    Also fix some ssr issues

- feat: support \_\_MarkTemplateElement, \_\_MarkPartElement and
\_\_GetTemplateParts for all-on-ui
([#1275](#1275))

-   Updated dependencies \[]:
    -   @lynx-js/[email protected]

## @lynx-js/[email protected]

### Patch Changes

- feat: support SSR for all-on-ui
([#1029](#1029))

- feat: move SSR hydrate essential info to the ssr attribute
([#1292](#1292))

We found that in browser there is no simple tool to decode a base64
string

    Therefore we move the data to `ssr` attribute

    Also fix some ssr issues

- feat: support \_\_MarkTemplateElement, \_\_MarkPartElement and
\_\_GetTemplateParts for all-on-ui
([#1275](#1275))

- feat: mark template elements for SSR and update part ID handling
([#1286](#1286))

- Updated dependencies
\[[`cebda59`](cebda59),
[`1443e46`](1443e46),
[`5062128`](5062128),
[`f656b7f`](f656b7f)]:
    -   @lynx-js/[email protected]
    -   @lynx-js/[email protected]
    -   @lynx-js/[email protected]
    -   @lynx-js/[email protected]

## @lynx-js/[email protected]

### Patch Changes

- feat: support SSR for all-on-ui
([#1029](#1029))

- feat: move SSR hydrate essential info to the ssr attribute
([#1292](#1292))

We found that in browser there is no simple tool to decode a base64
string

    Therefore we move the data to `ssr` attribute

    Also fix some ssr issues

- feat: dump the event info on ssr stage
([#1237](#1237))

- feat: mark template elements for SSR and update part ID handling
([#1286](#1286))

## @lynx-js/[email protected]

### Patch Changes

- fix: indicator dots' bg-color on safari 26
([#1298](#1298))

    <https://bugs.webkit.org/show_bug.cgi?id=296048>
    The animation name should be defined in the template

- fix: list may only render only one column in ReactLynx.
([#1280](#1280))

This is because `span-count` may not be specified when `list-type` is
specified, resulting in layout according to `span-count="1"`. Postponing
the acquisition of `span-count` until layoutListItem can solve this
problem.

- Updated dependencies
\[[`443f3d5`](443f3d5)]:
    -   @lynx-js/[email protected]

## @lynx-js/[email protected]

### Patch Changes

- fix: indicator dots' bg-color on safari 26
([#1298](#1298))

    <https://bugs.webkit.org/show_bug.cgi?id=296048>
    The animation name should be defined in the template

## @lynx-js/[email protected]

### Patch Changes

- feat: support SSR for all-on-ui
([#1029](#1029))

- feat: move SSR hydrate essential info to the ssr attribute
([#1292](#1292))

We found that in browser there is no simple tool to decode a base64
string

    Therefore we move the data to `ssr` attribute

    Also fix some ssr issues

- feat: support \_\_MarkTemplateElement, \_\_MarkPartElement and
\_\_GetTemplateParts for all-on-ui
([#1275](#1275))

- feat: mark template elements for SSR and update part ID handling
([#1286](#1286))

- Updated dependencies
\[[`1443e46`](1443e46),
[`5062128`](5062128)]:
    -   @lynx-js/[email protected]

## @lynx-js/[email protected]

### Patch Changes

- Updated dependencies
\[[`cebda59`](cebda59),
[`1443e46`](1443e46),
[`5062128`](5062128),
[`f656b7f`](f656b7f)]:
    -   @lynx-js/[email protected]
    -   @lynx-js/[email protected]
    -   @lynx-js/[email protected]

## @lynx-js/[email protected]

### Patch Changes

- Fix the `Syntax Error: expecting ';'` error of chunk splitting
([#1279](#1279))

## [email protected]



## @lynx-js/[email protected]

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

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants