# @solid-primitives/focus ## 1.0.0 ### Major Changes - ddf4ecd: Migrate to Solid.js v2.0 (beta.14) ## Breaking Changes **Peer dependencies**: `solid-js@^2.0.0-beta.14` and `@solidjs/web@^2.0.0-beta.14` are now required. - `autofocus` is now a **ref callback factory** (`use:autofocus` directive removed; Solid 2.0 no longer supports `use:` directives): ```tsx // Before // After // Before // After ``` - `JSX` type is now imported from `@solidjs/web` (was `solid-js`) - `onMount` replaced by `onSettled` from `solid-js` - `createAutofocus` uses split `createEffect(compute, apply)` form with proper timeout cleanup on re-focus ## New Primitives `makeFocusListener` and `createFocusSignal` have moved here from `@solid-primitives/active-element`: - **`makeFocusListener(target, callback, useCapture?)`** — attaches `focus`/`blur` listeners to an element, calling `callback` with the new boolean focus state. Returns a cleanup function. ```ts const clear = makeFocusListener(el, isFocused => console.log(isFocused)); clear(); // remove listeners ``` - **`createFocusSignal(target)`** — reactive signal that tracks whether `target` is focused. ```ts const isFocused = createFocusSignal(() => el); isFocused(); // boolean ``` ### Minor Changes - b7ef2f3: Add `createFocusRestore` — saves the currently focused element while active and restores focus to it once deactivated, without trapping focus or managing tab order. For non-modal surfaces (Popover, Tooltip, Menu) that should return focus to their trigger on close but must not intercept Tab navigation while open; for modal dialogs needing both behaviors, use `createFocusTrap`'s existing `restoreFocus` option instead. Also fixed a stale-closure race shared between `createFocusTrap` and the new `createFocusRestore`: the restore target used to be read from a mutable outer variable inside a deferred `afterPaint` callback, so a fast reactivate-before-restore-fires cycle could restore focus to the wrong element. Both primitives now share one internal helper that captures the target synchronously at deactivation time. - 53d9fee: Add `createFocusGroup` — creates a focus group for moving focus imperatively (`focusNext`/`focusPrevious`/`focusFirst`/`focusLast`) between the focusable/tabbable elements of a container, with arrow-key/Home/End/Tab keyboard navigation enabled by default (a `keydown` listener attached to the group's ref, removed on ref change or disposal). Useful for building menus, listboxes, toolbars, and other composite widgets that need roving-tabindex-style navigation. Options split into two groups: `from`, `tabbable`, `wrap`, and `accept` are traversal options that can be passed per-method-call or as defaults (the second argument to `createFocusGroup`); `orientation`, `textDirection`, `handleTab`, and `keyboardNavigation` are group-level keyboard options read only from those defaults. Radio button groups are handled per native semantics: with `tabbable: true`, only one `` per same-`name` group is tabbable at a time (the checked one, or the first if none is checked), matching browser roving-tabindex behavior for radio groups. ### Patch Changes - 50e36c9: Bump the `solid-js`/`@solidjs/web` peer and dev dependency range to `2.0.0-beta.20`. No API or behavior changes; beta.19/beta.20 introduced no breaking changes upstream (internal tree-shaking work, a new `solid-js/refresh` HMR entry point, and SSR/hydration/`lazy()` bug fixes). - c98cb2d: Bump the `solid-js`/`@solidjs/web`/`@solidjs/signals`/`babel-preset-solid` peer and dev dependency range to `2.0.0-rc.0`. No API or behavior changes on our end — this tracks upstream's move from the beta series into the release candidate. - 1b703e1: Bump the `solid-js`/`@solidjs/web`/`@solidjs/signals` peer and dev dependency range to `2.0.0-rc.14`. - 638c530: Bump the `solid-js`/`@solidjs/web`/`@solidjs/signals` peer and dev dependency range to `2.0.0-rc.9`, and `babel-preset-solid` to `2.0.0-rc.2`. Two behavior fixes were needed to keep up with upstream changes in this range: - `@solid-primitives/deep`: `captureStoreUpdates` no longer missed property changes. As of `2.0.0-rc.1` a store's `[$TRACK]` only fires for structural changes (key additions/removals), so leaf value changes stopped being reported. Each node's direct property values are now tracked individually. Updates are still reported at the shallowest node that actually changed. - `@solid-primitives/storage`: `makePersisted` no longer persists stale data. Signal writes stay pending until the next flush in `2.0.0-rc.1`+, so reading the value back inside the setter returned the _previous_ one — persisting stale data, or removing the stored entry entirely when the previous value was nullish. The value returned by the setter is now persisted directly. - Updated dependencies [89c5324] - Updated dependencies [cc30d55] - Updated dependencies [5fc4efa] - Updated dependencies [a47cf15] - Updated dependencies [ab4c926] - Updated dependencies [4a5bf32] - Updated dependencies [dd165cd] - Updated dependencies [7ee755d] - Updated dependencies [50e36c9] - Updated dependencies [c98cb2d] - Updated dependencies [1b703e1] - Updated dependencies [638c530] - Updated dependencies [04a170e] - Updated dependencies [91a92aa] - Updated dependencies [b7ef2f3] - Updated dependencies [5c23fda] - @solid-primitives/utils@7.0.0 - @solid-primitives/event-listener@3.0.0 ## 1.0.0-next.6 ### Patch Changes - 1b703e1: Bump the `solid-js`/`@solidjs/web`/`@solidjs/signals` peer and dev dependency range to `2.0.0-rc.14`. - Updated dependencies [1b703e1] - @solid-primitives/event-listener@3.0.0-next.7 - @solid-primitives/utils@7.0.0-next.6 ## 1.0.0-next.5 ### Patch Changes - 638c530: Bump the `solid-js`/`@solidjs/web`/`@solidjs/signals` peer and dev dependency range to `2.0.0-rc.9`, and `babel-preset-solid` to `2.0.0-rc.2`. Two behavior fixes were needed to keep up with upstream changes in this range: - `@solid-primitives/deep`: `captureStoreUpdates` no longer missed property changes. As of `2.0.0-rc.1` a store's `[$TRACK]` only fires for structural changes (key additions/removals), so leaf value changes stopped being reported. Each node's direct property values are now tracked individually. Updates are still reported at the shallowest node that actually changed. - `@solid-primitives/storage`: `makePersisted` no longer persists stale data. Signal writes stay pending until the next flush in `2.0.0-rc.1`+, so reading the value back inside the setter returned the _previous_ one — persisting stale data, or removing the stored entry entirely when the previous value was nullish. The value returned by the setter is now persisted directly. - Updated dependencies [7ee755d] - Updated dependencies [638c530] - @solid-primitives/utils@7.0.0-next.5 - @solid-primitives/event-listener@3.0.0-next.6 ## 1.0.0-next.4 ### Patch Changes - Bump the `solid-js`/`@solidjs/web`/`@solidjs/signals`/`babel-preset-solid` peer and dev dependency range to `2.0.0-rc.0`. No API or behavior changes on our end — this tracks upstream's move from the beta series into the release candidate. - Updated dependencies - @solid-primitives/event-listener@3.0.0-next.3 - @solid-primitives/utils@7.0.0-next.4 ## 1.0.0-next.3 ### Minor Changes - 53d9fee: Add `createFocusGroup` — creates a focus group for moving focus imperatively (`focusNext`/`focusPrevious`/`focusFirst`/`focusLast`) between the focusable/tabbable elements of a container, with arrow-key/Home/End/Tab keyboard navigation enabled by default (a `keydown` listener attached to the group's ref, removed on ref change or disposal). Useful for building menus, listboxes, toolbars, and other composite widgets that need roving-tabindex-style navigation. Options split into two groups: `from`, `tabbable`, `wrap`, and `accept` are traversal options that can be passed per-method-call or as defaults (the second argument to `createFocusGroup`); `orientation`, `textDirection`, `handleTab`, and `keyboardNavigation` are group-level keyboard options read only from those defaults. Radio button groups are handled per native semantics: with `tabbable: true`, only one `` per same-`name` group is tabbable at a time (the checked one, or the first if none is checked), matching browser roving-tabindex behavior for radio groups. ## 1.0.0-next.2 ### Minor Changes - b7ef2f3: Add `createFocusRestore` — saves the currently focused element while active and restores focus to it once deactivated, without trapping focus or managing tab order. For non-modal surfaces (Popover, Tooltip, Menu) that should return focus to their trigger on close but must not intercept Tab navigation while open; for modal dialogs needing both behaviors, use `createFocusTrap`'s existing `restoreFocus` option instead. Also fixed a stale-closure race shared between `createFocusTrap` and the new `createFocusRestore`: the restore target used to be read from a mutable outer variable inside a deferred `afterPaint` callback, so a fast reactivate-before-restore-fires cycle could restore focus to the wrong element. Both primitives now share one internal helper that captures the target synchronously at deactivation time. ### Patch Changes - Updated dependencies [b7ef2f3] - @solid-primitives/utils@7.0.0-next.3 ## 1.0.0-next.1 ### Patch Changes - 50e36c9: Bump the `solid-js`/`@solidjs/web` peer and dev dependency range to `2.0.0-beta.20`. No API or behavior changes; beta.19/beta.20 introduced no breaking changes upstream (internal tree-shaking work, a new `solid-js/refresh` HMR entry point, and SSR/hydration/`lazy()` bug fixes). - Updated dependencies [50e36c9] - @solid-primitives/event-listener@3.0.0-next.2 - @solid-primitives/utils@7.0.0-next.2 ## 1.0.0-next.0 ### Major Changes - ddf4ecd: Migrate to Solid.js v2.0 (beta.14) ## Breaking Changes **Peer dependencies**: `solid-js@^2.0.0-beta.14` and `@solidjs/web@^2.0.0-beta.14` are now required. - `autofocus` is now a **ref callback factory** (`use:autofocus` directive removed; Solid 2.0 no longer supports `use:` directives): ```tsx // Before // After // Before // After ``` - `JSX` type is now imported from `@solidjs/web` (was `solid-js`) - `onMount` replaced by `onSettled` from `solid-js` - `createAutofocus` uses split `createEffect(compute, apply)` form with proper timeout cleanup on re-focus ## New Primitives `makeFocusListener` and `createFocusSignal` have moved here from `@solid-primitives/active-element`: - **`makeFocusListener(target, callback, useCapture?)`** — attaches `focus`/`blur` listeners to an element, calling `callback` with the new boolean focus state. Returns a cleanup function. ```ts const clear = makeFocusListener(el, isFocused => console.log(isFocused)); clear(); // remove listeners ``` - **`createFocusSignal(target)`** — reactive signal that tracks whether `target` is focused. ```ts const isFocused = createFocusSignal(() => el); isFocused(); // boolean ``` ### Patch Changes - Updated dependencies [89c5324] - Updated dependencies [4a5bf32] - @solid-primitives/utils@7.0.0-next.0 - @solid-primitives/event-listener@3.0.0-next.0 ## 0.1.4 ### Patch Changes - Updated dependencies [6680ab9] - @solid-primitives/utils@6.4.0 ## 0.1.3 ### Patch Changes - 48d890d: Add missing type keyword to type imports. ## 0.1.2 ### Patch Changes - 396812d: Enable verbatimModuleSyntax -> add `type` keyword to all type imports. - Updated dependencies [396812d] - @solid-primitives/utils@6.3.2 ## 0.1.1 ### Patch Changes - 53f08cc: fix: Move `"@solid-primitives/source"` export condition under import in package.json (Fixes #774, Fixes #749) - Updated dependencies [53f08cc] - @solid-primitives/utils@6.3.1 ## 0.1.0 ### Minor Changes - ea09f71: Remove CJS support. The package is ESM only now. ### Patch Changes - Updated dependencies [ea09f71] - @solid-primitives/utils@6.3.0 ## 0.0.111 ### Patch Changes - 74db287: Correct the "homepage" field in package.json ## 0.0.110 ### Patch Changes - Updated dependencies [48d44c0] - @solid-primitives/utils@6.2.3 ## 0.0.109 ### Patch Changes - d23dd74: Add type exports for cjs - Updated dependencies [d23dd74] - @solid-primitives/utils@6.2.2 ## 0.0.108 ### Patch Changes - Updated dependencies [92c1e5c4] - @solid-primitives/utils@6.2.1 ## 0.0.107 ### Patch Changes - Updated dependencies [3c007b92] - @solid-primitives/utils@6.2.0 ## 0.0.106 ### Patch Changes - Updated dependencies [2e0bcedf] - @solid-primitives/utils@6.1.1 ## 0.0.105 ### Patch Changes - e0d87bcf: Make `autofocus` usable with `ref` ## 0.0.104 ### Patch Changes - Updated dependencies [2f6d3732] - @solid-primitives/utils@6.0.0 ## 0.0.103 ### Patch Changes - 3fad3789: Revert from publishing separate server, development, and production builds that has to rely on export conditions to publishing a single build that can be used in any environment. Envs will be checked at with `isDev`and `isServer` consts exported by `"solid-js/web"` so it's still tree-shakeable. - Updated dependencies [3fad3789] - @solid-primitives/utils@5.5.1 ## 0.0.102 ### Patch Changes - Updated dependencies [d6559a32] - @solid-primitives/utils@5.4.0 ## 0.0.102-beta.0 ### Patch Changes - Updated dependencies [d6559a32] - @solid-primitives/utils@5.4.0-beta.0 ## 0.0.101 ### Patch Changes - 865d5ee9: Fix build. (remove keepNames option) - Updated dependencies [865d5ee9] - @solid-primitives/utils@5.2.1