Olddevs UI4.14.0

Common problems

Troubleshooting

Escape in a dropdown also closes the dialog

Symptom. A Dialog is open with a Select, TimePicker or calendar expanded inside it. Pressing Escape should close only the topmost layer, the dropdown. Instead it closes the dialog too, taking the unsaved form with it.

Cause. Your app has more than one copy of @radix-ui/react-dismissable-layer. Radix keeps the stack of open layers in a module-level variable, so every copy of the module has its own independent stack, and each layer believes it is the topmost one. Radix pins its internal packages to exact versions, with no caret, so dialog, popover and tooltip released at different times pull in different copies, and npm has to duplicate them. Nothing looks wrong in the layout; the problem shows only in behavior.

How to check. There should be exactly one copy:

npm ls @radix-ui/react-dismissable-layer
find node_modules -name "react-dismissable-layer" -type d   # exactly one match

In the npm ls output there is one version, and the other occurrences are marked deduped.

How to fix. Radix comes with the kit (ADR-0072), and on a fresh install dialog, popover, tooltip and context-menu all resolve to one copy of react-dismissable-layer. A second copy appears when something else pulls Radix into the app: your own code or another library. First, line up the versions so that every package pulls in the same copy. The kit is tested on dialog@1.1.23, popover@1.1.23, tooltip@1.2.16 and context-menu@2.3.7, which all resolve to react-dismissable-layer@1.1.19. If versions alone cannot bring them together, pin one copy with overrides in your app's package.json:

{
  "overrides": {
    "@radix-ui/react-dismissable-layer": "1.1.19"
  }
}

In pnpm this is pnpm.overrides; in Yarn it is resolutions. The ranges in the kit's dependencies do not help here: the package cannot see which internal versions your package manager will choose. Repeat the check after every Radix update. react-focus-scope and react-presence also keep module-level state, so check their copies too.

Symptom. The package is installed from a local path, with npm i file:../olddevs_ui or npm link, and the app crashes with "Invalid hook call" for no obvious reason.

Cause. A package installed this way is a symlink to the kit's working copy. It resolves React from its own node_modules, where React is installed as a development dependency. The app ends up with two instances of React. peerDependencies do not prevent this: they apply when you install from the registry, not through a symlink.

How to check. Both paths should lead to the same file:

node -p "require.resolve('react')"
node -p "require.resolve('react', { paths: [require('fs').realpathSync('node_modules/@olddevs/ui')] })"

Prefer a published version: npm i @olddevs/ui@X.Y.Z, an exact version with no caret. If you need a local build, pack it into a tarball (npm pack in the kit's repository) and install that: npm i ../olddevs_ui/olddevs-ui-X.Y.Z.tgz. Installing from a tarball puts a real copy instead of a symlink, so there is no second React.

If you have to keep the symlink, make your bundler resolve React to a single copy. In Vite:

// vite.config.ts
export default { resolve: { dedupe: ["react", "react-dom"] } };

Other bundlers do the same with an alias that points react and react-dom at the copies in your app's node_modules (in Next.js, resolve.alias in the webpack function of next.config.js). Before you commit, put the registry version back in package.json.

On this page