Registry / web-framework / solid-dismissible

solid-dismissible

JSON →
library0.1.1jsnpmunverified

solid-dismissible is a foundational utility for SolidJS applications, designed to manage the dismissal behavior of UI layers such as dialogs, dropdowns, or tooltips. It provides a headless API, allowing developers to integrate dismissible logic without imposing specific styling or DOM structure. Key features include support for arbitrarily nested dismissible layers, where only the topmost active layer responds to dismiss actions, and multiple dismissal strategies such as outside pointer events (down/up), loss of focus outside the component, and the Escape key. Each strategy can be individually enabled, disabled, or customized. The current version is 0.1.1, and its last publish date was 2 years ago, indicating it is an early-stage library, part of the broader @corvu UI primitives ecosystem for SolidJS. Due to its early version, the API is subject to potential breaking changes in future minor releases, though its core functionality for handling dismissal logic is well-defined. This utility differentiates itself by offering robust nesting capabilities and fine-grained control over dismissal events, making it a powerful tool for complex interactive UIs.

npm install solid-dismissible
INSTALL
IMPORT
SIG · SOLID-DISMISSIBLE
S
solid-dismissible
web-frameworkjavascriptv0.1.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Dismissible
import Dismissible from 'solid-dismissible'
import { Dismissible } from 'solid-dismissible'
Dismissible is the default export of the package, providing the core component for managing dismissible layers.
activeDismissibles
import { activeDismissibles } from 'solid-dismissible'
import activeDismissibles from 'solid-dismissible'
This is a named export, a SolidJS signal that tracks the IDs of currently active dismissible layers for advanced management.
DismissibleProps
import type { DismissibleProps } from 'solid-dismissible'
Import the TypeScript type for the Dismissible component's props for type-safe usage.

This example demonstrates how to create a basic dismissible dialog component using `solid-dismissible`, managing its open state and dismissal logic.

import { createSignal, Show, type Component } from 'solid-js'; import Dismissible from 'solid-dismissible'; const DialogContent: Component<{ open: boolean; setOpen: (open: boolean) => void }> = (props) => { const [contentRef, setContentRef] = createSignal<HTMLElement | null>(null); return ( <Dismissible element={contentRef} enabled={props.open()} onDismiss={() => props.setOpen(false)} // Optional: Prevent dismissal on outside focus // dismissOnOutsideFocus={false} // Optional: Prevent dismissal on escape key // dismissOnEscape={false} > <Show when={props.open()}> <div ref={setContentRef} tabIndex={-1} // Make div focusable for testing focus dismissal style={{ border: '1px solid gray', padding: '20px', background: 'white', position: 'fixed', top: '50%', left: '50%', transform: 'translate(-50%, -50%)', zIndex: 1000 }} > <h2>Dismissible Dialog</h2> <p>Click outside or press Escape to dismiss.</p> <button onClick={() => props.setOpen(false)}>Close</button> </div> </Show> </Dismissible> ); }; const App: Component = () => { const [dialogOpen, setDialogOpen] = createSignal(false); return ( <div> <button onClick={() => setDialogOpen(true)}>Open Dialog</button> <DialogContent open={dialogOpen} setOpen={setDialogOpen} /> <p>This is content behind the dialog.</p> <p>Try opening the dialog and clicking outside or pressing Escape.</p> </div> ); }; export default App;
Debug
Known issues
breakingAs a package in early development (version 0.1.1), `solid-dismissible` may introduce breaking changes in future minor versions (e.g., 0.2.0, 0.3.0) without adhering strictly to semantic versioning until version 1.0.0 is reached.
fix
Review the package's changelog or GitHub releases for specific breaking changes when upgrading to new minor versions. Update your component implementations accordingly.
affects: <1.0.0
gotchaIncorrectly configuring the `element` prop or allowing it to be `null` or `undefined` can lead to the dismissible component not functioning, as it relies on a valid DOM element to track outside interactions.
fix
Ensure the `element` prop is always set to a `Signal<HTMLElement | null>` that will eventually resolve to a valid DOM element ref, usually via `ref={setElementRef}`.
affects: >=0.1.0
gotchaWhen nesting `Dismissible` components, improper management of the `enabled` prop or `onDismiss` callbacks can lead to unintended dismissal of parent layers or prevent deeper layers from dismissing correctly. The library is designed to support nesting, but careful state management is required.
fix
Always ensure the `enabled` prop accurately reflects the current visibility/interactability of a dismissible layer. Use the `onDismiss` callback to update the state that controls `enabled`, and consider how nested components' `onDismiss` might affect their parents.
affects: >=0.1.0
Errors
Common errors & fixes
TypeError: Cannot read properties of null (reading 'ownerDocument')
The `element` prop passed to `Dismissible` was null or undefined when the component attempted to register global event listeners.
fix
Ensure the DOM element for `Dismissible` is rendered and its ref (`element` prop) is available before `Dismissible` attempts to initialize. Use SolidJS's `createSignal` for the ref and conditionally render the dismissible content with `Show` or `onMount` to guarantee the element exists.
Dismissible layer not closing when expected (e.g., clicking outside or pressing Escape)
The `enabled` prop is `false`, or the `onDismiss` callback does not correctly update the state controlling the `enabled` prop.
fix
Verify that `enabled={true}` when the dismissible layer should be active. Confirm that the `onDismiss` callback correctly updates the state variable (e.g., `setOpen(false)`) that controls the `enabled` prop, causing the component to react and dismiss.
Nested dismissible layers close prematurely or in the wrong order.
While `solid-dismissible` supports nesting, the parent layers might not be correctly 'disabled' or 'paused' when a child layer is active, causing parent dismissal events to propagate.
fix
Ensure that when a child dismissible layer is `enabled`, any parent dismissible layers have their `enabled` prop dynamically set to `false` or leverage the `activeDismissibles` signal to prevent parent dismissal logic from firing until the child is dismissed. The library handles the core nesting logic, but your state management must reflect the active layer hierarchy.
Upgrade
Version history
0.1.1latest on npm
Audit
Dependencies
solid-jsrequiredSolidJS is the peer dependency for the library's components and reactivity system.
Agent activity
2 hits · last 30 days
node
2
Resources
solid-dismissible — npm install solid-dismissible · libregistry