Skip to content

fix(lit-virtual): add setOptions to VirtualizerController for reactive option updates - #1253

Open
waterWang wants to merge 2 commits into
TanStack:mainfrom
waterWang:fix/lit-virtual-setOptions
Open

fix(lit-virtual): add setOptions to VirtualizerController for reactive option updates#1253
waterWang wants to merge 2 commits into
TanStack:mainfrom
waterWang:fix/lit-virtual-setOptions

Conversation

@waterWang

@waterWang waterWang commented Aug 12, 2026

Copy link
Copy Markdown

Description

Fixes #1251

() never calls after the initial construction, so reactive option updates (a changed , , , etc.) never reach the underlying instance.

Root cause

The constructor captures options once and passes them to . The lifecycle method only calls without re-applying options. Every other framework adapter (, ) calls before every .

Fix

  1. Added method to — stores the options on the instance, merges with new partial options, and calls + . Matches the pattern used by 's and 's injectable.

  2. Stored as a private field — enables the method to merge partial updates with the base options (including defaults from and subclass constructors).

Consumer usage

Changes

  • : Added method, stored as private field
  • : Added test verifying renders items beyond the initial count of 10

Summary by CodeRabbit

  • New Features

    • Added the ability to update virtualizer options dynamically during rendering.
    • Changes to options now immediately refresh the displayed item range and count.
  • Tests

    • Added coverage confirming that updated item counts render newly available items correctly.

@coderabbitai

coderabbitai Bot commented Aug 12, 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: 25ca0c64-2677-4427-879d-32d97020388b

📥 Commits

Reviewing files that changed from the base of the PR and between d2cf98b and e548ded.

📒 Files selected for processing (2)
  • packages/lit-virtual/src/index.ts
  • packages/lit-virtual/tests/index.test.ts

📝 Walkthrough

Walkthrough

VirtualizerControllerBase now supports runtime option updates through setOptions(). The update path preserves callbacks, applies merged options to the virtualizer, and triggers its lifecycle. A test verifies that changing count renders item index 15.

Changes

Lit virtualizer option updates

Layer / File(s) Summary
Controller option update flow
packages/lit-virtual/src/index.ts
The controller stores its options and adds setOptions() to merge updates, rebuild onChange, update the virtualizer, and invoke _willUpdate().
Rendering validation
packages/lit-virtual/tests/index.test.ts
A test changes the count from 10 to 20 during rendering and verifies that item index 15 renders.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the addition of setOptions for reactive lit-virtual option updates.
Description check ✅ Passed The description explains the bug, root cause, implementation, issue reference, and test coverage, so it is mostly complete.
Linked Issues check ✅ Passed The PR adds a public setOptions channel, merges options, updates the virtualizer, and tests reactive count changes as required by issue #1251.
Out of Scope Changes check ✅ Passed The changes are limited to the requested controller API update and its focused regression test.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

packages/lit-virtual/tests/index.test.ts

Parsing error: "parserOptions.project" has been provided for @typescript-eslint/parser.
The file was not found in any of the provided project(s): packages/lit-virtual/tests/index.test.ts


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.

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.

lit-virtual: VirtualizerController never applies updated options after construction

1 participant