-
Notifications
You must be signed in to change notification settings - Fork 111
fix(web): list may only render only one column in ReactLynx #1280
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
🦋 Changeset detectedLatest commit: d1f296c The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
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 |
7d68639 to
d1f296c
Compare
WalkthroughThe 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
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
Poem
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
ERROR Cannot resolve version $@rspack/core in overrides. The direct dependencies don't have dependency "@rspack/core". ✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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, anduseEffectbut 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
⛔ 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.pngis excluded by!**/*.pngpackages/web-platform/web-tests/tests/react.spec.ts-snapshots/list/basic-element-list-waterfall/initial-firefox-linux.pngis excluded by!**/*.pngpackages/web-platform/web-tests/tests/react.spec.ts-snapshots/list/basic-element-list-waterfall/initial-webkit-linux.pngis 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
spanCountandisScrollVerticalfrom DOM attributes internally addresses the core issue wherespan-countmight not be available whenlist-typeis 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 ReportAll modified and coverable lines are covered by tests ✅ ✅ All tests successful. No failed tests found. 📢 Thoughts on this report? Let us know! |
CodSpeed Performance ReportMerging #1280 will not alter performanceComparing Summary
|
React Example#2897 Bundle Size — 234.12KiB (0%).d1f296c(current) vs d938579 main#2889(baseline) Bundle metrics
|
| Current #2897 |
Baseline #2889 |
|
|---|---|---|
0B |
0B |
|
0B |
0B |
|
0% |
0% |
|
0 |
0 |
|
4 |
4 |
|
153 |
153 |
|
61 |
61 |
|
45.85% |
45.85% |
|
2 |
2 |
|
0 |
0 |
Bundle size by type no changes
| Current #2897 |
Baseline #2889 |
|
|---|---|---|
145.76KiB |
145.76KiB |
|
88.37KiB |
88.37KiB |
Bundle analysis report Branch Sherry-hue:fix/rl-list-waterfall Project dashboard
Generated by RelativeCI Documentation Report issue
Web Explorer#2888 Bundle Size — 303.03KiB (~-0.01%).d1f296c(current) vs d938579 main#2880(baseline) Bundle metrics
Bundle size by type
Bundle analysis report Branch Sherry-hue:fix/rl-list-waterfall Project dashboard Generated by RelativeCI Documentation Report issue |
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>
fix: list may only render only one column in ReactLynx.
This is because
span-countmay not be specified whenlist-typeis specified, resulting in layout according tospan-count="1". Postponing the acquisition ofspan-countuntil layoutListItem can solve this problem.Summary
Checklist
Summary by CodeRabbit
Bug Fixes
Tests
Style
New Features