Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(lemon-ui): stop tooltip roots retaining closed popup dom (#120529)

posthog[bot]bc18825351e7
diff --git a/patches/@[email protected] b/patches/@[email protected]
new file mode 100644
index 000000000000..6c3dbb677b14
--- /dev/null
+++ b/patches/@[email protected]
@@ -0,0 +1,99 @@
+diff --git a/floating-ui-react/components/FloatingRootStore.js b/floating-ui-react/components/FloatingRootStore.js
+index 8fb20046bfb360ba4346f4889888dec0d0bf0539..25ac2ae9f54884a8f0447106d022d4ab96eb7475 100644
+--- a/floating-ui-react/components/FloatingRootStore.js
++++ b/floating-ui-react/components/FloatingRootStore.js
+@@ -4,6 +4,8 @@ Object.defineProperty(exports, "__esModule", {
+ value: true
+ });
+ exports.FloatingRootStore = void 0;
++var _react = require("react");
++var _shim = require("use-sync-external-store/shim");
+ var _store = require("@base-ui/utils/store");
+ var _createEventEmitter = require("../utils/createEventEmitter");
+ var _utils = require("../utils");
+@@ -40,6 +42,13 @@ class FloatingRootStore extends _store.ReactStore {
+ this.syncOnly = syncOnly;
+ }
+
++ // The selector shim retains a full snapshot, including a closed popup's DOM.
++ useState(key, a1, a2, a3) {
++ const selector = this.selectors[key];
++ const getSelection = _react.useCallback(() => selector(this.getSnapshot(), a1, a2, a3), [this, selector, a1, a2, a3]);
++ return (0, _shim.useSyncExternalStore)(this.subscribe, getSelection, getSelection);
++ }
++
+ /**
+ * Syncs the event used by hover logic to distinguish hover-open from click-like interaction.
+ */
+diff --git a/floating-ui-react/components/FloatingRootStore.mjs b/floating-ui-react/components/FloatingRootStore.mjs
+index 94b43928a84001be7bf3494b4ba9b6455582594d..25673142688d1927580a22b38da58153d1f0e679 100644
+--- a/floating-ui-react/components/FloatingRootStore.mjs
++++ b/floating-ui-react/components/FloatingRootStore.mjs
+@@ -1,3 +1,5 @@
++import * as React from 'react';
++import { useSyncExternalStore } from 'use-sync-external-store/shim';
+ import { ReactStore } from '@base-ui/utils/store';
+ import { createEventEmitter } from "../utils/createEventEmitter.mjs";
+ import { isClickLikeEvent } from "../utils.mjs";
+@@ -34,6 +36,13 @@ export class FloatingRootStore extends ReactStore {
+ this.syncOnly = syncOnly;
+ }
+
++ // The selector shim retains a full snapshot, including a closed popup's DOM.
++ useState(key, a1, a2, a3) {
++ const selector = this.selectors[key];
++ const getSelection = React.useCallback(() => selector(this.getSnapshot(), a1, a2, a3), [this, selector, a1, a2, a3]);
++ return useSyncExternalStore(this.subscribe, getSelection, getSelection);
++ }
++
+ /**
+ * Syncs the event used by hover logic to distinguish hover-open from click-like interaction.
+ */
+diff --git a/floating-ui-react/hooks/useFloating.js b/floating-ui-react/hooks/useFloating.js
+index 7bdfd0b459d3a05afa98241d9e9d629a2bd1cb1c..e9dffdd7893aaf73aabff97fa90d3c2d9f6d6fe6 100644
+--- a/floating-ui-react/hooks/useFloating.js
++++ b/floating-ui-react/hooks/useFloating.js
+@@ -82,11 +82,18 @@ function useBaseUIFloating(options) {
+ }
+ }, [domReferenceElement]);
+ (0, _useIsoLayoutEffect.useIsoLayoutEffect)(() => {
+- store.context.dataRef.current.floatingContext = context;
++ const dataRef = store.context.dataRef;
++ dataRef.current.floatingContext = context;
+ const node = tree?.nodesRef.current.find(n => n.id === nodeId);
+ if (node) {
+ node.context = context;
+ }
++ return () => {
++ // The root store outlives the floating element, so a stale context retains the detached popup.
++ if (dataRef.current.floatingContext === context) {
++ dataRef.current.floatingContext = undefined;
++ }
++ };
+ });
+ return React.useMemo(() => ({
+ ...position,
+diff --git a/floating-ui-react/hooks/useFloating.mjs b/floating-ui-react/hooks/useFloating.mjs
+index 44fa4b5199a9d419d47a8091e16a6244e74b1997..e946673346f0493c16bd0703775bc0926f84d36b 100644
+--- a/floating-ui-react/hooks/useFloating.mjs
++++ b/floating-ui-react/hooks/useFloating.mjs
+@@ -76,11 +76,18 @@ export function useBaseUIFloating(options) {
+ }
+ }, [domReferenceElement]);
+ useIsoLayoutEffect(() => {
+- store.context.dataRef.current.floatingContext = context;
++ const dataRef = store.context.dataRef;
++ dataRef.current.floatingContext = context;
+ const node = tree?.nodesRef.current.find(n => n.id === nodeId);
+ if (node) {
+ node.context = context;
+ }
++ return () => {
++ // The root store outlives the floating element, so a stale context retains the detached popup.
++ if (dataRef.current.floatingContext === context) {
++ dataRef.current.floatingContext = undefined;
++ }
++ };
+ });
+ return React.useMemo(() => ({
+ ...position,
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index fe58a1a7c866..21733f6043e0 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -7,8 +7,8 @@ settings:
catalogs:
default:
'@base-ui/react':
- specifier: 1.8.0
- version: 1.8.0
+ specifier: 1.9.0
+ version: 1.9.0
'@parcel/packager-ts':
specifier: 2.16.4
version: 2.16.4
@@ -189,6 +189,9 @@ overrides:
'@tiptap/extension-underline': 3.20.6
patchedDependencies:
+ '@base-ui/[email protected]':
+ hash: e0be9f964398f2e05b65153968c757a2869a3c5ddc6c2d3a32bf3140a4a8b34f
+ path: patches/@[email protected]
'@connectrpc/[email protected]':
hash: a8248109885bda6ff3ce8663332190cabec9ca5da4deab47603ea6b1dbca27c4
path: patches/@[email protected]
@@ -583,7 +586,7 @@ importers:
dependencies:
'@base-ui/react':
specifier: 'catalog:'
+ version: 1.9.0(patch_hash=e0be9f964398f2e05b65153968c757a2869a3c5ddc6c2d3a32bf3140a4a8b34f)(@types/[email protected])([email protected])([email protected]([email protected]))([email protected])
'@dagrejs/dagre':
specifier: ^1.1.5
version: 1.1.5
@@ -2212,7 +2215,7 @@ importers:
dependencies:
'@base-ui/react':
specifier: 'catalog:'
+ version: 1.9.0(patch_hash=e0be9f964398f2e05b65153968c757a2869a3c5ddc6c2d3a32bf3140a4a8b34f)(@types/[email protected])([email protected])([email protected]([email protected]))([email protected])
'@posthog/quill-tokens':
specifier: workspace:^
version: link:../tokens
@@ -2292,7 +2295,7 @@ importers:
devDependencies:
'@base-ui/react':
specifier: 'catalog:'
+ version: 1.9.0(patch_hash=e0be9f964398f2e05b65153968c757a2869a3c5ddc6c2d3a32bf3140a4a8b34f)(@types/[email protected])([email protected])([email protected]([email protected]))([email protected])
'@posthog/quill-blocks':
specifier: workspace:*
version: link:../blocks
@@ -3728,7 +3731,7 @@ importers:
dependencies:
'@base-ui/react':
specifier: 'catalog:'
+ version: 1.9.0(patch_hash=e0be9f964398f2e05b65153968c757a2869a3c5ddc6c2d3a32bf3140a4a8b34f)(@types/[email protected])([email protected])([email protected]([email protected]))([email protected])
'@dnd-kit/core':
specifier: '*'
@@ -6042,6 +6045,21 @@ importers:
packages:
+ resolution: {integrity: sha512-6L+EeigHMQhdaIPNIFUKwfWJSwWFQ8gJbJ2DLOs5sDIegTwR9fRxvnM3uciHKjIZhFz+KAv2emhWMRvDmMcY8A==}
+ peerDependencies:
+ react: 18.3.1
+ resolution: {integrity: sha512-XGoLeRAVzUTcJ1qkxPQhDJyIZ5d6zzZD9nT7AEZOaaU9UbWclhycElmhO+VD5bFeLuzhPBaOV2oXC8uG35ZSpg==}
+ '@base-ui/[email protected]':
+ resolution: {integrity: sha512-dYGGcEttjkYiMoa5nHm8vLaJ2UcuTWxo3BFAwOYXeRg/q7UVVvA6cacEIXEs3FgBfK1CGtW1ptElqs7wsx+t9A==}
+ peerDependencies:
+ '@types/react': 18.3.27
+ react: 18.3.1
+ react-dom: 18.3.1
+ peerDependenciesMeta:
+ '@types/react':
+ optional: true
'@aashutoshrathi/[email protected]':
resolution: {integrity: sha512-1Yjs2SvM8TflER/OD3cOjhWWOZb58A2t7wpE2S9XfBYTiIl+XFhQG2bjy4Pu1I+EAlCNUzRDYDdFwFYUKvXcIA==}
engines: {node: '>=0.10.0'}
@@ -7277,8 +7295,8 @@ packages:
resolution: {integrity: sha512-LwdZHpScM4Qz8Xw2iKSzS+cfglZzJGvofQICy7W7v4caru4EaAmyUuO6BGrbyQ2mYV11W0U8j5mBhd14dd3B0A==}
engines: {node: '>=6.9.0'}
- '@base-ui/[email protected]':
- resolution: {integrity: sha512-P0/1sxo6SBVZOklKMIedvTWqw2s2IQzi9x5bIVsXu980cuSOD4NeuRSs+/L7LZQfDkZP/uRZyGPyfFl/B1oH+Q==}
+ '@base-ui/[email protected]':
+ resolution: {integrity: sha512-S8CSYosASBKtpL8SWUfS78rFElfLijiCgA7oHOK22jCJ95FULsYyKwBNFOgudt0RA+/7yNc7F81bOvQnRgbBiQ==}
engines: {node: '>=14.0.0'}
peerDependencies:
'@date-fns/tz': ^1.2.0
@@ -24062,6 +24080,21 @@ packages:
snapshots:
+
+ dependencies:
+ react: 18.3.1
+ dependencies:
+ '@babel/runtime': 7.29.7
+ '@floating-ui/utils': 0.2.12
+ react: 18.3.1
+ react-dom: 18.3.1([email protected])
+ reselect: 5.3.0
+ use-sync-external-store: 1.7.0([email protected])
+ optionalDependencies:
+ '@types/react': 18.3.27
'@aashutoshrathi/[email protected]': {}
'@actions/[email protected]': {}
@@ -26365,17 +26398,16 @@ snapshots:
'@babel/helper-string-parser': 7.27.1
'@babel/helper-validator-identifier': 7.28.5
+ '@base-ui/[email protected](patch_hash=e0be9f964398f2e05b65153968c757a2869a3c5ddc6c2d3a32bf3140a4a8b34f)(@types/[email protected])([email protected])([email protected]([email protected]))([email protected])':
dependencies:
'@babel/runtime': 7.29.7
'@floating-ui/react-dom': 2.1.9([email protected]([email protected]))([email protected])
'@floating-ui/utils': 0.2.12
react: 18.3.1
react-dom: 18.3.1([email protected])
- use-sync-external-store: 1.6.0([email protected])
+ use-sync-external-store: 1.7.0([email protected])
optionalDependencies:
- '@date-fns/tz': 1.4.1
'@types/react': 18.3.27
date-fns: 4.1.0
diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml
index e3e2307ce833..d2d31209b40e 100644
--- a/pnpm-workspace.yaml
+++ b/pnpm-workspace.yaml
@@ -122,6 +122,8 @@ patchedDependencies:
+ # A mounted tooltip root must not keep its closed popup's detached DOM alive.
+ '@base-ui/[email protected]': patches/@[email protected]
# Dependencies that require preinstall scripts. Add entries with caution.
allowBuilds:
@@ -198,7 +200,7 @@ catalog:
# React types
'@types/react': ^18.3.27
'@types/react-dom': ^18.3.7
- '@base-ui/react': 1.8.0
+ '@base-ui/react': 1.9.0
# Other shared
husky: ^7.0.4
lint-staged: ~15.4.3