@octanejs/floating-ui 0.1.69 → 0.1.70
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/UPSTREAM.md +8 -0
- package/dist/cjs/react-dom.cjs +84 -0
- package/dist/cjs/useFloating.cjs +15 -4
- package/package.json +10 -4
- package/src/react-dom.ts +107 -0
- package/src/types.ts +1 -1
- package/src/useFloating.ts +28 -5
- package/src/utils/index.ts +1 -1
package/README.md
CHANGED
|
@@ -28,3 +28,7 @@ import { useFloating, useInteractions, useHover, offset, flip } from '@octanejs/
|
|
|
28
28
|
Current scope, known divergences, and verification status are tracked in the
|
|
29
29
|
generated [bindings status table](../../docs/bindings-status.md), sourced from
|
|
30
30
|
this package's [`status.json`](./status.json).
|
|
31
|
+
|
|
32
|
+
For positioning without interaction context, import `useFloating` and middleware from
|
|
33
|
+
`@octanejs/floating-ui/react-dom`. It exposes the `@floating-ui/react-dom` positioning API,
|
|
34
|
+
including middleware dependency lists and the DOM library's `autoUpdate`.
|
package/UPSTREAM.md
CHANGED
|
@@ -39,3 +39,11 @@ The package's older differential lane remains supplemental evidence: it
|
|
|
39
39
|
compiles one repository fixture for React and Octane and compares independent
|
|
40
40
|
hook placement output. Real Chromium layout and `autoUpdate` coverage remains
|
|
41
41
|
in the ordinary `floating-ui-browser` project.
|
|
42
|
+
|
|
43
|
+
## Positioning-only entry
|
|
44
|
+
|
|
45
|
+
The `@octanejs/floating-ui/react-dom` entry tracks `@floating-ui/react-dom@2.1.9` at
|
|
46
|
+
[`12d94738472e922e1b3fa31b02b2b61b9ed77e6a`](https://github.com/floating-ui/floating-ui/tree/12d94738472e922e1b3fa31b02b2b61b9ed77e6a/packages/react-dom).
|
|
47
|
+
The npm tarball integrity is `sha512-JDjEFGCpImxDCA7JJKviA0M9+RtmJdj0m/NVU5IMgBK+AmZouAQQ7/+2GLH0GXXY0YMw9oXPB8hKdbPYg5QLYg==`.
|
|
48
|
+
The positioning hook and reactive middleware have the same runtime implementation as the vendored 2.1.8 sources.
|
|
49
|
+
The 2.1.9 declarations accept explicit `undefined` in optional arrow padding and positioning options.
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var react_dom_exports = {};
|
|
30
|
+
__export(react_dom_exports, {
|
|
31
|
+
arrow: () => arrow,
|
|
32
|
+
autoPlacement: () => autoPlacement,
|
|
33
|
+
autoUpdate: () => import_dom.autoUpdate,
|
|
34
|
+
computePosition: () => import_dom.computePosition,
|
|
35
|
+
detectOverflow: () => import_dom.detectOverflow,
|
|
36
|
+
flip: () => flip,
|
|
37
|
+
getOverflowAncestors: () => import_dom.getOverflowAncestors,
|
|
38
|
+
hide: () => hide,
|
|
39
|
+
inline: () => inline,
|
|
40
|
+
limitShift: () => limitShift,
|
|
41
|
+
offset: () => offset,
|
|
42
|
+
platform: () => import_dom.platform,
|
|
43
|
+
shift: () => shift,
|
|
44
|
+
size: () => size,
|
|
45
|
+
useFloating: () => import_useFloating2.useFloating
|
|
46
|
+
});
|
|
47
|
+
module.exports = __toCommonJS(react_dom_exports);
|
|
48
|
+
var dom = __toESM(require("@floating-ui/dom"), 1);
|
|
49
|
+
var import_useFloating = require("./useFloating.cjs");
|
|
50
|
+
var import_dom = require("@floating-ui/dom");
|
|
51
|
+
var import_useFloating2 = require("./useFloating.cjs");
|
|
52
|
+
function metadata(result, options, deps) {
|
|
53
|
+
return { name: result.name, fn: result.fn, options: [options, deps] };
|
|
54
|
+
}
|
|
55
|
+
const arrow = (options, deps) => metadata((0, import_useFloating.arrow)(options), options, deps);
|
|
56
|
+
const autoPlacement = (options, deps) => metadata(dom.autoPlacement(options), options, deps);
|
|
57
|
+
const flip = (options, deps) => metadata(dom.flip(options), options, deps);
|
|
58
|
+
const hide = (options, deps) => metadata(dom.hide(options), options, deps);
|
|
59
|
+
const inline = (options, deps) => metadata(dom.inline(options), options, deps);
|
|
60
|
+
const limitShift = (options, deps) => ({
|
|
61
|
+
fn: dom.limitShift(options).fn,
|
|
62
|
+
options: [options, deps]
|
|
63
|
+
});
|
|
64
|
+
const offset = (options, deps) => metadata(dom.offset(options), options, deps);
|
|
65
|
+
const shift = (options, deps) => metadata(dom.shift(options), options, deps);
|
|
66
|
+
const size = (options, deps) => metadata(dom.size(options), options, deps);
|
|
67
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
68
|
+
0 && (module.exports = {
|
|
69
|
+
arrow,
|
|
70
|
+
autoPlacement,
|
|
71
|
+
autoUpdate,
|
|
72
|
+
computePosition,
|
|
73
|
+
detectOverflow,
|
|
74
|
+
flip,
|
|
75
|
+
getOverflowAncestors,
|
|
76
|
+
hide,
|
|
77
|
+
inline,
|
|
78
|
+
limitShift,
|
|
79
|
+
offset,
|
|
80
|
+
platform,
|
|
81
|
+
shift,
|
|
82
|
+
size,
|
|
83
|
+
useFloating
|
|
84
|
+
});
|
package/dist/cjs/useFloating.cjs
CHANGED
|
@@ -19,6 +19,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
19
19
|
var useFloating_exports = {};
|
|
20
20
|
__export(useFloating_exports, {
|
|
21
21
|
arrow: () => arrow,
|
|
22
|
+
useFloating: () => useFloating,
|
|
22
23
|
usePositionFloating: () => usePositionFloating
|
|
23
24
|
});
|
|
24
25
|
module.exports = __toCommonJS(useFloating_exports);
|
|
@@ -39,7 +40,14 @@ function useLatestRef(value, slot) {
|
|
|
39
40
|
}
|
|
40
41
|
function usePositionFloating(args) {
|
|
41
42
|
const [user, slot] = (0, import_internal.splitSlot)(args);
|
|
42
|
-
|
|
43
|
+
return usePositionCore(user[0], slot, "interactions");
|
|
44
|
+
}
|
|
45
|
+
function useFloating(options, slot = void 0) {
|
|
46
|
+
if (typeof options === "symbol") return usePositionCore(void 0, options, "positioning");
|
|
47
|
+
return usePositionCore(options, slot, "positioning");
|
|
48
|
+
}
|
|
49
|
+
function usePositionCore(input, slot, mode) {
|
|
50
|
+
const options = input ?? {};
|
|
43
51
|
const placement = options.placement ?? "bottom";
|
|
44
52
|
const strategy = options.strategy ?? "absolute";
|
|
45
53
|
const middleware = options.middleware ?? [];
|
|
@@ -66,6 +74,7 @@ function usePositionFloating(args) {
|
|
|
66
74
|
latestMiddlewareRef.current.revision += 1;
|
|
67
75
|
}
|
|
68
76
|
const middlewareRevision = latestMiddlewareRef.current.revision;
|
|
77
|
+
const middlewareAtRender = latestMiddlewareRef.current.value;
|
|
69
78
|
const [_reference, _setReference] = (0, import_octane.useState)(null, (0, import_internal.subSlot)(slot, "ref"));
|
|
70
79
|
const [_floating, _setFloating] = (0, import_octane.useState)(null, (0, import_internal.subSlot)(slot, "flo"));
|
|
71
80
|
const referenceRef = (0, import_octane.useRef)(null, (0, import_internal.subSlot)(slot, "rref"));
|
|
@@ -75,7 +84,7 @@ function usePositionFloating(args) {
|
|
|
75
84
|
const setReference = (0, import_octane.useCallback)(
|
|
76
85
|
(node) => {
|
|
77
86
|
const detach = ++referenceDetachRef.current;
|
|
78
|
-
if (node === null) {
|
|
87
|
+
if (node === null && mode === "interactions") {
|
|
79
88
|
queueMicrotask(() => {
|
|
80
89
|
const current = referenceRef.current;
|
|
81
90
|
if (referenceDetachRef.current === detach && current !== null && (!(current instanceof Element) || !current.isConnected)) {
|
|
@@ -96,7 +105,7 @@ function usePositionFloating(args) {
|
|
|
96
105
|
const setFloating = (0, import_octane.useCallback)(
|
|
97
106
|
(node) => {
|
|
98
107
|
const detach = ++floatingDetachRef.current;
|
|
99
|
-
if (node === null) {
|
|
108
|
+
if (node === null && mode === "interactions") {
|
|
100
109
|
queueMicrotask(() => {
|
|
101
110
|
const current = floatingRef.current;
|
|
102
111
|
if (floatingDetachRef.current === detach && current !== null && !current.isConnected) {
|
|
@@ -130,7 +139,8 @@ function usePositionFloating(args) {
|
|
|
130
139
|
const config = {
|
|
131
140
|
placement,
|
|
132
141
|
strategy,
|
|
133
|
-
middleware
|
|
142
|
+
// A positioning update retained from an earlier render keeps its middleware.
|
|
143
|
+
middleware: mode === "positioning" ? middlewareAtRender : latestMiddlewareRef.current.value
|
|
134
144
|
};
|
|
135
145
|
if (platformRef.current) {
|
|
136
146
|
config.platform = platformRef.current;
|
|
@@ -246,5 +256,6 @@ const arrow = (options) => {
|
|
|
246
256
|
// Annotate the CommonJS export names for ESM import in node:
|
|
247
257
|
0 && (module.exports = {
|
|
248
258
|
arrow,
|
|
259
|
+
useFloating,
|
|
249
260
|
usePositionFloating
|
|
250
261
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@octanejs/floating-ui",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.70",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -45,6 +45,12 @@
|
|
|
45
45
|
"import": "./src/index.ts",
|
|
46
46
|
"require": "./dist/cjs/index.cjs",
|
|
47
47
|
"default": "./src/index.ts"
|
|
48
|
+
},
|
|
49
|
+
"./react-dom": {
|
|
50
|
+
"types": "./src/react-dom.ts",
|
|
51
|
+
"import": "./src/react-dom.ts",
|
|
52
|
+
"require": "./dist/cjs/react-dom.cjs",
|
|
53
|
+
"default": "./src/react-dom.ts"
|
|
48
54
|
}
|
|
49
55
|
},
|
|
50
56
|
"dependencies": {
|
|
@@ -53,10 +59,10 @@
|
|
|
53
59
|
"tabbable": "^6.5.0"
|
|
54
60
|
},
|
|
55
61
|
"peerDependencies": {
|
|
56
|
-
"octane": "^0.
|
|
62
|
+
"octane": "^0.17.0"
|
|
57
63
|
},
|
|
58
64
|
"devDependencies": {
|
|
59
|
-
"@octanejs/testing-library": "0.1.
|
|
65
|
+
"@octanejs/testing-library": "0.1.69",
|
|
60
66
|
"@radix-ui/react-checkbox": "1.0.4",
|
|
61
67
|
"@radix-ui/react-icons": "1.3.0",
|
|
62
68
|
"@testing-library/jest-dom": "6.6.3",
|
|
@@ -70,7 +76,7 @@
|
|
|
70
76
|
"@floating-ui/react-dom": "2.1.8",
|
|
71
77
|
"esbuild": "^0.28.1",
|
|
72
78
|
"clsx": "1.2.1",
|
|
73
|
-
"octane": "0.
|
|
79
|
+
"octane": "0.17.0",
|
|
74
80
|
"playwright": "^1.61.1",
|
|
75
81
|
"react": "18.2.0",
|
|
76
82
|
"react-dom": "18.2.0",
|
package/src/react-dom.ts
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import * as dom from '@floating-ui/dom';
|
|
2
|
+
import type { ComputePositionConfig } from '@floating-ui/dom';
|
|
3
|
+
import type { CSSProperties } from 'octane/jsx-runtime';
|
|
4
|
+
import { arrow as refArrow } from './useFloating';
|
|
5
|
+
import type { ReferenceType, UsePositionFloatingReturn } from './types';
|
|
6
|
+
|
|
7
|
+
export {
|
|
8
|
+
autoUpdate,
|
|
9
|
+
computePosition,
|
|
10
|
+
detectOverflow,
|
|
11
|
+
getOverflowAncestors,
|
|
12
|
+
platform,
|
|
13
|
+
} from '@floating-ui/dom';
|
|
14
|
+
export { useFloating } from './useFloating';
|
|
15
|
+
export type {
|
|
16
|
+
ArrowOptions,
|
|
17
|
+
ReferenceType,
|
|
18
|
+
UsePositionFloatingData as UseFloatingData,
|
|
19
|
+
} from './types';
|
|
20
|
+
export type {
|
|
21
|
+
AlignedPlacement,
|
|
22
|
+
Alignment,
|
|
23
|
+
AutoPlacementOptions,
|
|
24
|
+
AutoUpdateOptions,
|
|
25
|
+
Axis,
|
|
26
|
+
Boundary,
|
|
27
|
+
ClientRectObject,
|
|
28
|
+
ComputePositionConfig,
|
|
29
|
+
ComputePositionReturn,
|
|
30
|
+
Coords,
|
|
31
|
+
Derivable,
|
|
32
|
+
DetectOverflowOptions,
|
|
33
|
+
Dimensions,
|
|
34
|
+
ElementContext,
|
|
35
|
+
ElementRects,
|
|
36
|
+
Elements,
|
|
37
|
+
FlipOptions,
|
|
38
|
+
FloatingElement,
|
|
39
|
+
HideOptions,
|
|
40
|
+
InlineOptions,
|
|
41
|
+
Length,
|
|
42
|
+
Middleware,
|
|
43
|
+
MiddlewareArguments,
|
|
44
|
+
MiddlewareData,
|
|
45
|
+
MiddlewareReturn,
|
|
46
|
+
MiddlewareState,
|
|
47
|
+
NodeScroll,
|
|
48
|
+
OffsetOptions,
|
|
49
|
+
Padding,
|
|
50
|
+
Placement,
|
|
51
|
+
Platform,
|
|
52
|
+
Rect,
|
|
53
|
+
ReferenceElement,
|
|
54
|
+
RootBoundary,
|
|
55
|
+
ShiftOptions,
|
|
56
|
+
Side,
|
|
57
|
+
SideObject,
|
|
58
|
+
SizeOptions,
|
|
59
|
+
Strategy,
|
|
60
|
+
VirtualElement,
|
|
61
|
+
} from '@floating-ui/dom';
|
|
62
|
+
|
|
63
|
+
export type UseFloatingOptions<RT extends ReferenceType = ReferenceType> =
|
|
64
|
+
Partial<ComputePositionConfig> & {
|
|
65
|
+
whileElementsMounted?:
|
|
66
|
+
((reference: RT, floating: HTMLElement, update: () => void) => () => void) | undefined;
|
|
67
|
+
elements?:
|
|
68
|
+
{ reference?: RT | null | undefined; floating?: HTMLElement | null | undefined } | undefined;
|
|
69
|
+
open?: boolean | undefined;
|
|
70
|
+
transform?: boolean | undefined;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export type UseFloatingReturn<RT extends ReferenceType = ReferenceType> = Omit<
|
|
74
|
+
UsePositionFloatingReturn<RT>,
|
|
75
|
+
'floatingStyles'
|
|
76
|
+
> & { floatingStyles: CSSProperties };
|
|
77
|
+
|
|
78
|
+
type Dependencies = readonly unknown[];
|
|
79
|
+
type Reactive<F extends (...args: never[]) => unknown> = (
|
|
80
|
+
...args: [...Parameters<F>, deps?: Dependencies]
|
|
81
|
+
) => ReturnType<F>;
|
|
82
|
+
|
|
83
|
+
// Upstream compares the dependency list alongside options that capture a closure.
|
|
84
|
+
function metadata(result: dom.Middleware, options: unknown, deps?: Dependencies): dom.Middleware {
|
|
85
|
+
return { name: result.name, fn: result.fn, options: [options, deps] };
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export const arrow: Reactive<typeof refArrow> = (options, deps) =>
|
|
89
|
+
metadata(refArrow(options), options, deps);
|
|
90
|
+
export const autoPlacement: Reactive<typeof dom.autoPlacement> = (options, deps) =>
|
|
91
|
+
metadata(dom.autoPlacement(options), options, deps);
|
|
92
|
+
export const flip: Reactive<typeof dom.flip> = (options, deps) =>
|
|
93
|
+
metadata(dom.flip(options), options, deps);
|
|
94
|
+
export const hide: Reactive<typeof dom.hide> = (options, deps) =>
|
|
95
|
+
metadata(dom.hide(options), options, deps);
|
|
96
|
+
export const inline: Reactive<typeof dom.inline> = (options, deps) =>
|
|
97
|
+
metadata(dom.inline(options), options, deps);
|
|
98
|
+
export const limitShift: Reactive<typeof dom.limitShift> = (options, deps) => ({
|
|
99
|
+
fn: dom.limitShift(options).fn,
|
|
100
|
+
options: [options, deps],
|
|
101
|
+
});
|
|
102
|
+
export const offset: Reactive<typeof dom.offset> = (options, deps) =>
|
|
103
|
+
metadata(dom.offset(options), options, deps);
|
|
104
|
+
export const shift: Reactive<typeof dom.shift> = (options, deps) =>
|
|
105
|
+
metadata(dom.shift(options), options, deps);
|
|
106
|
+
export const size: Reactive<typeof dom.size> = (options, deps) =>
|
|
107
|
+
metadata(dom.size(options), options, deps);
|
package/src/types.ts
CHANGED
|
@@ -158,7 +158,7 @@ export interface ArrowOptions {
|
|
|
158
158
|
* Useful when the floating element has rounded corners.
|
|
159
159
|
* @default 0
|
|
160
160
|
*/
|
|
161
|
-
padding?: Padding;
|
|
161
|
+
padding?: Padding | undefined;
|
|
162
162
|
}
|
|
163
163
|
|
|
164
164
|
// ─── Interaction context (the @floating-ui/react `useFloating` surface) ──────
|
package/src/useFloating.ts
CHANGED
|
@@ -12,6 +12,7 @@ import type {
|
|
|
12
12
|
} from '@floating-ui/dom';
|
|
13
13
|
import { flushSync, useCallback, useLayoutEffect, useMemo, useRef, useState } from 'octane';
|
|
14
14
|
|
|
15
|
+
import type { UseFloatingOptions, UseFloatingReturn } from './react-dom';
|
|
15
16
|
import { splitSlot, subSlot } from './internal';
|
|
16
17
|
import { deepEqual, getDPR, roundByDPR } from './utils';
|
|
17
18
|
import type {
|
|
@@ -52,9 +53,29 @@ export function usePositionFloating<RT extends ReferenceType = any>(
|
|
|
52
53
|
// Loose fallback: pre-typing callers built untyped option bags in plain `.ts`;
|
|
53
54
|
// they keep compiling while still receiving the typed return.
|
|
54
55
|
export function usePositionFloating(args: unknown[]): UsePositionFloatingReturn<any>;
|
|
55
|
-
export function usePositionFloating(args:
|
|
56
|
+
export function usePositionFloating(args: unknown[]): UsePositionFloatingReturn<any> {
|
|
56
57
|
const [user, slot] = splitSlot(args);
|
|
57
|
-
|
|
58
|
+
return usePositionCore(user[0], slot, 'interactions');
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function useFloating<RT extends ReferenceType = ReferenceType>(
|
|
62
|
+
options?: UseFloatingOptions,
|
|
63
|
+
): UseFloatingReturn<RT>;
|
|
64
|
+
export function useFloating(
|
|
65
|
+
options?: UseFloatingOptions | symbol,
|
|
66
|
+
slot: symbol | undefined = undefined,
|
|
67
|
+
): UseFloatingReturn<any> {
|
|
68
|
+
// A compiled call without options passes its slot as the first argument.
|
|
69
|
+
if (typeof options === 'symbol') return usePositionCore(undefined, options, 'positioning');
|
|
70
|
+
return usePositionCore(options, slot, 'positioning');
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function usePositionCore(
|
|
74
|
+
input: UsePositionFloatingOptions | UseFloatingOptions | undefined,
|
|
75
|
+
slot: symbol | undefined,
|
|
76
|
+
mode: 'interactions' | 'positioning',
|
|
77
|
+
): UsePositionFloatingReturn<any> {
|
|
78
|
+
const options = input ?? {};
|
|
58
79
|
|
|
59
80
|
const placement = options.placement ?? 'bottom';
|
|
60
81
|
const strategy = options.strategy ?? 'absolute';
|
|
@@ -88,6 +109,7 @@ export function usePositionFloating(args: any[]): any {
|
|
|
88
109
|
latestMiddlewareRef.current.revision += 1;
|
|
89
110
|
}
|
|
90
111
|
const middlewareRevision = latestMiddlewareRef.current.revision;
|
|
112
|
+
const middlewareAtRender = latestMiddlewareRef.current.value;
|
|
91
113
|
|
|
92
114
|
const [_reference, _setReference] = useState<ReferenceType | null>(null, subSlot(slot, 'ref'));
|
|
93
115
|
const [_floating, _setFloating] = useState<HTMLElement | null>(null, subSlot(slot, 'flo'));
|
|
@@ -100,7 +122,7 @@ export function usePositionFloating(args: any[]): any {
|
|
|
100
122
|
const setReference = useCallback(
|
|
101
123
|
(node: ReferenceType | null) => {
|
|
102
124
|
const detach = ++referenceDetachRef.current;
|
|
103
|
-
if (node === null) {
|
|
125
|
+
if (node === null && mode === 'interactions') {
|
|
104
126
|
queueMicrotask(() => {
|
|
105
127
|
const current = referenceRef.current;
|
|
106
128
|
if (
|
|
@@ -125,7 +147,7 @@ export function usePositionFloating(args: any[]): any {
|
|
|
125
147
|
const setFloating = useCallback(
|
|
126
148
|
(node: HTMLElement | null) => {
|
|
127
149
|
const detach = ++floatingDetachRef.current;
|
|
128
|
-
if (node === null) {
|
|
150
|
+
if (node === null && mode === 'interactions') {
|
|
129
151
|
queueMicrotask(() => {
|
|
130
152
|
const current = floatingRef.current;
|
|
131
153
|
if (floatingDetachRef.current === detach && current !== null && !current.isConnected) {
|
|
@@ -162,7 +184,8 @@ export function usePositionFloating(args: any[]): any {
|
|
|
162
184
|
const config: Partial<ComputePositionConfig> = {
|
|
163
185
|
placement,
|
|
164
186
|
strategy,
|
|
165
|
-
middleware
|
|
187
|
+
// A positioning update retained from an earlier render keeps its middleware.
|
|
188
|
+
middleware: mode === 'positioning' ? middlewareAtRender : latestMiddlewareRef.current.value,
|
|
166
189
|
};
|
|
167
190
|
if (platformRef.current) {
|
|
168
191
|
config.platform = platformRef.current;
|
package/src/utils/index.ts
CHANGED