Skip to content

upgrade: page-utilities packages migration and adaptation upgrade for Solid 2.0 #901

Open
davedbase wants to merge 3 commits into
solidjs-community:nextfrom
davedbase:update/v2/page-visibility
Open

upgrade: page-utilities packages migration and adaptation upgrade for Solid 2.0 #901
davedbase wants to merge 3 commits into
solidjs-community:nextfrom
davedbase:update/v2/page-visibility

Conversation

@davedbase
Copy link
Copy Markdown
Member

@davedbase davedbase commented May 16, 2026

Migrates the former @solid-primitives/page-visibility package to Solid.js v2.0 (beta.13), adds two new navigation-blocking primitives, and renames the package to @solid-primitives/page-utilities to reflect its broader scope.

Solid 2.0 migration

  • isServer import moved from solid-js/web@solidjs/web
  • INTERNAL_OPTIONS (ownedWrite: true) added to the internal signal — required because DOM event handlers firing within an owned scope trigger Solid 2.0's write guard
  • flush() added in tests after dispatchEvent calls to commit pending signal values before asserting
  • test/server.test.ts added to verify SSR behaviour
  • Peer dependencies updated to solid-js@^2.0.0-beta.13 and @solidjs/web@^2.0.0-beta.13

New primitives: makePageLeave and createPageLeaveBlocker

makePageLeave is the base primitive — it attaches a beforeunload listener that calls e.preventDefault() to trigger the browser's built-in "Leave site?" dialog, and returns a cleanup function.

createPageLeaveBlocker is the reactive wrapper. It accepts an optional MaybeAccessor<boolean> (default true) so navigation blocking can be toggled reactively — the most practical pattern being gating on unsaved state:

const [isDirty, setIsDirty] = createSignal(false);
createPageLeaveBlocker(isDirty);

Static true/false wires up synchronously via onCleanup; a signal uses the Solid 2.0 split createEffect(compute, apply) pattern to arm and disarm the listener as the value changes.

Package rename

@solid-primitives/page-visibility@solid-primitives/page-utilities. The package now covers page-level browser concerns beyond just visibility, and the name change reflects that.

Breaking changes

  • Package renamed to @solid-primitives/page-utilities
  • Peer dependencies now require solid-js@^2.0.0-beta.13 and `@solidjs/web@^2.0.0-beta.13

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

changeset-bot Bot commented May 16, 2026

🦋 Changeset detected

Latest commit: 509e581

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

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

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