Skip to content

upgrade: selection package upgrade for Solid 2.0#895

Open
davedbase wants to merge 4 commits into
solidjs-community:nextfrom
davedbase:update/v2/selection
Open

upgrade: selection package upgrade for Solid 2.0#895
davedbase wants to merge 4 commits into
solidjs-community:nextfrom
davedbase:update/v2/selection

Conversation

@davedbase
Copy link
Copy Markdown
Member

@davedbase davedbase commented May 12, 2026

src/index.ts`

  • isServer import moved from solid-js/web@solidjs/web
  • INTERNAL_OPTIONS imported from @solid-primitives/utils and applied to both internal signals so setSelection can be called from reactive scopes
  • The first createEffect (event listener setup with no reactive deps) was removed — listeners now register directly with onCleanup
  • The second createEffect (DOM apply) converted to the Solid 2.0 split pattern: createEffect(compute, apply)

package.json

  • solid-js bumped to 2.0.0-beta.10 (peer + dev)
  • @solidjs/web: 2.0.0-beta.10 added (peer + dev)
  • @solid-primitives/utils: workspace:^ added as a runtime dependency
  • @babel/core and babel-preset-solid@2.0.0-beta.10 added as devDeps
  • vitest script points to a local vitest.config.ts

vitest.config.ts (new)

  • Custom config using babel-preset-solid with moduleName: "@solidjs/web", mirroring the virtual package's approach to work around the vite-plugin-solid / Solid 2.0 incompatibility

test/index.test.tsx

  • render import from @solidjs/web; flush imported from solid-js
  • All 6 tests rewritten: synchronous, inside createRoot, using dispatchEvent + flush() in place of the old await createEffect(async () => {...}) pattern

test/server.test.ts (new) — SSR no-op verification

.changeset/selection-solid2-migration.md — major bump changeset

Summary by CodeRabbit

Release Notes

  • New Features

    • Added compatibility with Solid.js v2.0 (beta.10) and @solidjs/web v2.0.
  • Bug Fixes

    • Enhanced event handling and server-side rendering support.
  • Documentation

    • Updated peer dependency requirements.

Review Change Stack

@davedbase davedbase added this to the Solid 2.0 Migration milestone May 12, 2026
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 12, 2026

🦋 Changeset detected

Latest commit: 6a4cc10

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

This PR includes changesets to release 1 package
Name Type
@solid-primitives/selection Major

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

@davedbase davedbase changed the title upgrade: selection packages upgrade for Solid 2.0 upgrade: selection package upgrade for Solid 2.0 May 12, 2026
@davedbase davedbase marked this pull request as ready for review May 17, 2026 13:14
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 23, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 7bf1573a-2b0c-483f-982c-fc8f957c0fd0

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Copy link
Copy Markdown

@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: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/selection/test/index.test.tsx`:
- Around line 103-105: Remove the conditional guards that allow tests to pass
when selection() is null: in the contentEditable tests replace the "if
(selection()[0] !== null) { expect(selection()).toEqual([div, 0, 6]); }" style
checks with deterministic assertions — e.g., first assert
expect(selection()[0]).not.toBeNull() (or expect(selection()).toHaveLength(3) as
appropriate) and then assert expect(selection()).toEqual([div, 0, 6]); do the
same for the other block (the assertions around lines 119-124) so the test fails
if selection() is unexpectedly null instead of skipping the core assertion.
- Around line 23-37: The test bodies call unmount() and dispose() only on the
success path, which leaks DOM/root state if an expect throws; wrap the test
logic inside a try/finally so that unmount() (from renderTest()) and dispose()
(from createRoot callback) are always called even on assertion failures, i.e.,
locate the createRoot(...) callback and surrounding code that uses renderTest(),
input, flush(), selection() and ensure the finally block calls unmount() and
dispose(); apply the same try/finally pattern to every test case (including the
ones spanning lines 40-52, 55-69, 72-84, 87-109, 112-128).

In `@packages/selection/test/server.test.ts`:
- Around line 8-9: The test currently calls setSelection with the initial tuple
which makes the no-op setter assertion weak; change the setter call in the test
to pass a distinct, non-default tuple (e.g., [1, 2, 3] or another clear
sentinel) via setSelection(...) and then assert that selection() still equals
the original [null, NaN, NaN]; update the lines using setSelection and the
subsequent expect to use the distinct input while keeping the expected value the
original tuple, referencing the setSelection and selection functions.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: ed495f96-23ae-4705-bcb7-01fef76759ea

📥 Commits

Reviewing files that changed from the base of the PR and between 76d6f2e and d4a4350.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (8)
  • .changeset/selection-solid2-migration.md
  • packages/selection/README.md
  • packages/selection/package.json
  • packages/selection/src/index.ts
  • packages/selection/test/index.test.tsx
  • packages/selection/test/server.test.ts
  • packages/selection/tsconfig.json
  • packages/selection/vitest.config.ts

Comment thread packages/selection/test/index.test.tsx
Comment thread packages/selection/test/index.test.tsx Outdated
Comment thread packages/selection/test/server.test.ts Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant