@octanejs/floating-ui 0.1.46 → 0.1.48

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.
@@ -60,16 +60,31 @@ function usePositionFloating(args) {
60
60
  },
61
61
  (0, import_internal.subSlot)(slot, "data")
62
62
  );
63
- const [latestMiddleware, setLatestMiddleware] = (0, import_octane.useState)(middleware, (0, import_internal.subSlot)(slot, "mw"));
64
- if (!(0, import_utils.deepEqual)(latestMiddleware, middleware)) {
65
- setLatestMiddleware(middleware);
63
+ const latestMiddlewareRef = (0, import_octane.useRef)({ value: middleware, revision: 0 }, (0, import_internal.subSlot)(slot, "mw"));
64
+ if (!(0, import_utils.deepEqual)(latestMiddlewareRef.current.value, middleware)) {
65
+ latestMiddlewareRef.current.value = middleware;
66
+ latestMiddlewareRef.current.revision += 1;
66
67
  }
68
+ const middlewareRevision = latestMiddlewareRef.current.revision;
67
69
  const [_reference, _setReference] = (0, import_octane.useState)(null, (0, import_internal.subSlot)(slot, "ref"));
68
70
  const [_floating, _setFloating] = (0, import_octane.useState)(null, (0, import_internal.subSlot)(slot, "flo"));
69
71
  const referenceRef = (0, import_octane.useRef)(null, (0, import_internal.subSlot)(slot, "rref"));
70
72
  const floatingRef = (0, import_octane.useRef)(null, (0, import_internal.subSlot)(slot, "rflo"));
73
+ const referenceDetachRef = (0, import_octane.useRef)(0, (0, import_internal.subSlot)(slot, "rdetach"));
74
+ const floatingDetachRef = (0, import_octane.useRef)(0, (0, import_internal.subSlot)(slot, "fdetach"));
71
75
  const setReference = (0, import_octane.useCallback)(
72
76
  (node) => {
77
+ const detach = ++referenceDetachRef.current;
78
+ if (node === null) {
79
+ queueMicrotask(() => {
80
+ const current = referenceRef.current;
81
+ if (referenceDetachRef.current === detach && current !== null && (!(current instanceof Element) || !current.isConnected)) {
82
+ referenceRef.current = null;
83
+ _setReference(null);
84
+ }
85
+ });
86
+ return;
87
+ }
73
88
  if (node !== referenceRef.current) {
74
89
  referenceRef.current = node;
75
90
  _setReference(node);
@@ -80,6 +95,17 @@ function usePositionFloating(args) {
80
95
  );
81
96
  const setFloating = (0, import_octane.useCallback)(
82
97
  (node) => {
98
+ const detach = ++floatingDetachRef.current;
99
+ if (node === null) {
100
+ queueMicrotask(() => {
101
+ const current = floatingRef.current;
102
+ if (floatingDetachRef.current === detach && current !== null && !current.isConnected) {
103
+ floatingRef.current = null;
104
+ _setFloating(null);
105
+ }
106
+ });
107
+ return;
108
+ }
83
109
  if (node !== floatingRef.current) {
84
110
  floatingRef.current = node;
85
111
  _setFloating(node);
@@ -104,7 +130,7 @@ function usePositionFloating(args) {
104
130
  const config = {
105
131
  placement,
106
132
  strategy,
107
- middleware: latestMiddleware
133
+ middleware: latestMiddlewareRef.current.value
108
134
  };
109
135
  if (platformRef.current) {
110
136
  config.platform = platformRef.current;
@@ -122,7 +148,7 @@ function usePositionFloating(args) {
122
148
  }
123
149
  });
124
150
  },
125
- [latestMiddleware, placement, strategy, platformRef, openRef],
151
+ [middlewareRevision, placement, strategy, platformRef, openRef],
126
152
  (0, import_internal.subSlot)(slot, "upd")
127
153
  );
128
154
  (0, import_octane.useLayoutEffect)(
@@ -32,7 +32,7 @@ __export(utils_exports, {
32
32
  execWithArgsOrReturn: () => execWithArgsOrReturn,
33
33
  findNonDisabledListIndex: () => findNonDisabledListIndex,
34
34
  getDPR: () => getDPR,
35
- getDeepestNode: () => getDeepestNode,
35
+ getDeepestNode: () => import_nodes.getDeepestNode,
36
36
  getDelay: () => getDelay,
37
37
  getDocument: () => getDocument,
38
38
  getFloatingFocusElement: () => getFloatingFocusElement,
@@ -42,8 +42,8 @@ __export(utils_exports, {
42
42
  getMaxListIndex: () => getMaxListIndex,
43
43
  getMinListIndex: () => getMinListIndex,
44
44
  getNextTabbable: () => getNextTabbable,
45
- getNodeAncestors: () => getNodeAncestors,
46
- getNodeChildren: () => getNodeChildren,
45
+ getNodeAncestors: () => import_nodes.getNodeAncestors,
46
+ getNodeChildren: () => import_nodes.getNodeChildren,
47
47
  getPlatform: () => getPlatform,
48
48
  getPreviousTabbable: () => getPreviousTabbable,
49
49
  getTabbableOptions: () => getTabbableOptions,
@@ -80,6 +80,7 @@ var import_utils = require("@floating-ui/utils");
80
80
  var import_tabbable = require("tabbable");
81
81
  var import_octane = require("octane");
82
82
  var import_internal = require("../internal.cjs");
83
+ var import_nodes = require("./nodes.cjs");
83
84
  function getPlatform() {
84
85
  const uaData = navigator.userAgentData;
85
86
  if (uaData != null && uaData.platform) {
@@ -194,43 +195,6 @@ function getFloatingFocusElement(floatingElement) {
194
195
  }
195
196
  return floatingElement.hasAttribute(FOCUSABLE_ATTRIBUTE) ? floatingElement : floatingElement.querySelector("[" + FOCUSABLE_ATTRIBUTE + "]") || floatingElement;
196
197
  }
197
- function getNodeChildren(nodes, id, onlyOpenChildren = true) {
198
- const directChildren = nodes.filter(
199
- (node) => node.parentId === id && (!onlyOpenChildren || node.context?.open)
200
- );
201
- return directChildren.flatMap((child) => [
202
- child,
203
- ...getNodeChildren(nodes, child.id, onlyOpenChildren)
204
- ]);
205
- }
206
- function getDeepestNode(nodes, id) {
207
- let deepestNodeId;
208
- let maxDepth = -1;
209
- function findDeepest(nodeId, depth) {
210
- if (depth > maxDepth) {
211
- deepestNodeId = nodeId;
212
- maxDepth = depth;
213
- }
214
- const children = getNodeChildren(nodes, nodeId);
215
- children.forEach((child) => {
216
- findDeepest(child.id, depth + 1);
217
- });
218
- }
219
- findDeepest(id, 0);
220
- return nodes.find((node) => node.id === deepestNodeId);
221
- }
222
- function getNodeAncestors(nodes, id) {
223
- let allAncestors = [];
224
- let currentParentId = nodes.find((node) => node.id === id)?.parentId;
225
- while (currentParentId) {
226
- const currentNode = nodes.find((node) => node.id === currentParentId);
227
- currentParentId = currentNode?.parentId;
228
- if (currentNode) {
229
- allAncestors = allAncestors.concat(currentNode);
230
- }
231
- }
232
- return allAncestors;
233
- }
234
198
  function stopEvent(event) {
235
199
  event.preventDefault();
236
200
  event.stopPropagation();
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var nodes_exports = {};
20
+ __export(nodes_exports, {
21
+ getDeepestNode: () => getDeepestNode,
22
+ getNodeAncestors: () => getNodeAncestors,
23
+ getNodeChildren: () => getNodeChildren
24
+ });
25
+ module.exports = __toCommonJS(nodes_exports);
26
+ function getNodeChildren(nodes, id, onlyOpenChildren = true) {
27
+ const directChildren = nodes.filter(
28
+ (node) => node.parentId === id && (!onlyOpenChildren || node.context?.open)
29
+ );
30
+ return directChildren.flatMap((child) => [
31
+ child,
32
+ ...getNodeChildren(nodes, child.id, onlyOpenChildren)
33
+ ]);
34
+ }
35
+ function getDeepestNode(nodes, id) {
36
+ const childrenByParent = /* @__PURE__ */ new Map();
37
+ for (const node of nodes) {
38
+ if (!node.context?.open) continue;
39
+ const siblings = childrenByParent.get(node.parentId);
40
+ if (siblings) {
41
+ siblings.push(node);
42
+ } else {
43
+ childrenByParent.set(node.parentId, [node]);
44
+ }
45
+ }
46
+ let deepestNodeId = id;
47
+ let maxDepth = 0;
48
+ const stack = [];
49
+ const rootChildren = childrenByParent.get(id);
50
+ if (rootChildren) {
51
+ for (let index = rootChildren.length - 1; index >= 0; index--) {
52
+ stack.push([rootChildren[index], 1]);
53
+ }
54
+ }
55
+ while (stack.length) {
56
+ const [node, depth] = stack.pop();
57
+ if (depth > maxDepth) {
58
+ deepestNodeId = node.id;
59
+ maxDepth = depth;
60
+ }
61
+ const children = childrenByParent.get(node.id);
62
+ if (children) {
63
+ for (let index = children.length - 1; index >= 0; index--) {
64
+ stack.push([children[index], depth + 1]);
65
+ }
66
+ }
67
+ }
68
+ return nodes.find((node) => node.id === deepestNodeId);
69
+ }
70
+ function getNodeAncestors(nodes, id) {
71
+ let allAncestors = [];
72
+ let currentParentId = nodes.find((node) => node.id === id)?.parentId;
73
+ while (currentParentId) {
74
+ const currentNode = nodes.find((node) => node.id === currentParentId);
75
+ currentParentId = currentNode?.parentId;
76
+ if (currentNode) {
77
+ allAncestors = allAncestors.concat(currentNode);
78
+ }
79
+ }
80
+ return allAncestors;
81
+ }
82
+ // Annotate the CommonJS export names for ESM import in node:
83
+ 0 && (module.exports = {
84
+ getDeepestNode,
85
+ getNodeAncestors,
86
+ getNodeChildren
87
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@octanejs/floating-ui",
3
- "version": "0.1.46",
3
+ "version": "0.1.48",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -33,7 +33,11 @@
33
33
  "files": [
34
34
  "src",
35
35
  "dist/cjs",
36
- "README.md"
36
+ "README.md",
37
+ "UPSTREAM.md",
38
+ "LICENSE",
39
+ "LICENSE.upstream",
40
+ "LICENSE.react.upstream"
37
41
  ],
38
42
  "exports": {
39
43
  ".": {
@@ -49,18 +53,45 @@
49
53
  "tabbable": "^6.5.0"
50
54
  },
51
55
  "peerDependencies": {
52
- "octane": "0.1.47"
56
+ "octane": "0.1.49"
53
57
  },
54
58
  "devDependencies": {
59
+ "@radix-ui/react-checkbox": "1.0.4",
60
+ "@radix-ui/react-icons": "1.3.0",
61
+ "@testing-library/jest-dom": "6.6.3",
62
+ "@testing-library/react": "16.2.0",
63
+ "@testing-library/user-event": "14.6.1",
64
+ "@types/react": "18.3.19",
65
+ "@types/react-dom": "18.3.1",
66
+ "@tsrx/react": "^0.2.61",
67
+ "@vitest/browser": "4.1.10",
55
68
  "@floating-ui/react": "0.27.19",
69
+ "@floating-ui/react-dom": "2.1.8",
56
70
  "esbuild": "^0.28.1",
57
- "react": "^19.2.7",
58
- "react-dom": "^19.2.7",
59
- "vitest": "^4.1.10",
60
- "octane": "0.1.47"
71
+ "clsx": "1.2.1",
72
+ "playwright": "^1.61.1",
73
+ "react": "18.2.0",
74
+ "react-dom": "18.2.0",
75
+ "react-responsive": "9.0.2",
76
+ "resize-observer-polyfill": "1.5.1",
77
+ "tabbable-pristine": "npm:tabbable@6.2.0",
78
+ "typescript": "5.4.2",
79
+ "use-isomorphic-layout-effect": "1.2.1",
80
+ "vite": "^8.1.5",
81
+ "vitest": "3.0.9",
82
+ "vitest-browser-react": "0.1.1",
83
+ "@octanejs/testing-library": "0.1.46",
84
+ "octane": "0.1.49"
61
85
  },
62
86
  "scripts": {
63
87
  "build:cjs": "node ../../scripts/build-package-commonjs.mjs",
64
- "test": "vitest run"
88
+ "test": "pnpm upstream:verify && node ../../scripts/react-parity/harness.mjs run-required --manifest packages/floating-ui/audit/react-parity.json && ../../node_modules/.bin/vitest run --root ../.. --project floating-ui",
89
+ "test:upstream": "node ../../scripts/react-parity/run-pristine.mjs floating-ui",
90
+ "test:adapted-upstream": "vitest run --config tests/adapted-vitest.config.ts",
91
+ "parity:evidence:generate": "node scripts/generate-parity-evidence.mjs",
92
+ "parity:evidence:check": "node scripts/generate-parity-evidence.mjs --check",
93
+ "typecheck": "tsrx-tsc --noEmit -p tsconfig.json && tsrx-tsc --noEmit -p typetests/tsconfig.adapted.json",
94
+ "typecheck:pristine": "tsc --noEmit -p typetests/tsconfig.pristine.json",
95
+ "upstream:verify": "node ../../scripts/react-parity/verify-provenance.mjs"
65
96
  }
66
97
  }
@@ -6,7 +6,7 @@
6
6
  // are returned as an ARRAY (octane renders it like a React fragment).
7
7
  import { getNodeName, isHTMLElement, isShadowRoot } from '@floating-ui/utils/dom';
8
8
  import { focusable, isTabbable, tabbable } from 'tabbable';
9
- import { createElement, useEffect, useMemo, useRef } from 'octane';
9
+ import { createElement, Fragment, useEffect, useMemo, useRef } from 'octane';
10
10
  import type { OctaneNode } from 'octane';
11
11
 
12
12
  import { FocusGuard, usePortalContext } from './FloatingPortal';
@@ -171,7 +171,7 @@ function applyAttributeToOthers(
171
171
  }
172
172
  };
173
173
  }
174
- function markOthers(avoidElements: any[], ariaHidden = false, inert = false): () => void {
174
+ export function markOthers(avoidElements: any[], ariaHidden = false, inert = false): () => void {
175
175
  const body = getDocument(avoidElements[0]).body;
176
176
  return applyAttributeToOthers(
177
177
  avoidElements.concat(Array.from(body.querySelectorAll('[aria-live],[role="status"],output'))),
@@ -849,6 +849,7 @@ export function FloatingFocusManager(props: FloatingFocusManagerProps): OctaneNo
849
849
  return null;
850
850
  }
851
851
  return createElement(VisuallyHiddenDismiss, {
852
+ key: `dismiss-${location}`,
852
853
  ref: location === 'start' ? startDismissButtonRef : endDismissButtonRef,
853
854
  onClick: (event: MouseEvent) => onOpenChange(false, event),
854
855
  children: typeof visuallyHiddenDismiss === 'string' ? visuallyHiddenDismiss : 'Dismiss',
@@ -861,54 +862,60 @@ export function FloatingFocusManager(props: FloatingFocusManagerProps): OctaneNo
861
862
  (modal ? !isUntrappedTypeableCombobox : true) &&
862
863
  (isInsidePortal || modal);
863
864
 
865
+ // Octane reconciles array children as keyed lists. Keep every conditional slot
866
+ // stable so changing guard/dismiss visibility cannot remount consumer content.
864
867
  return [
865
- shouldRenderGuards &&
866
- createElement(FocusGuard, {
867
- 'data-type': 'inside',
868
- ref: mergedBeforeGuardRef,
869
- onFocus: (event: FocusEvent) => {
870
- if (modal) {
871
- const els = getTabbableElements();
872
- enqueueFocus(order[0] === 'reference' ? els[0] : els[els.length - 1]);
873
- } else if (
874
- portalContext != null &&
875
- portalContext.preserveTabOrder &&
876
- portalContext.portalNode
877
- ) {
878
- preventReturnFocusRef.current = false;
879
- if (isOutsideEvent(event, portalContext.portalNode)) {
880
- getNextTabbable(domReference)?.focus();
881
- } else {
882
- portalContext.beforeOutsideRef.current?.focus();
868
+ shouldRenderGuards
869
+ ? createElement(FocusGuard, {
870
+ key: 'guard-inside-before',
871
+ 'data-type': 'inside',
872
+ ref: mergedBeforeGuardRef,
873
+ onFocus: (event: FocusEvent) => {
874
+ if (modal) {
875
+ const els = getTabbableElements();
876
+ enqueueFocus(order[0] === 'reference' ? els[0] : els[els.length - 1]);
877
+ } else if (
878
+ portalContext != null &&
879
+ portalContext.preserveTabOrder &&
880
+ portalContext.portalNode
881
+ ) {
882
+ preventReturnFocusRef.current = false;
883
+ if (isOutsideEvent(event, portalContext.portalNode)) {
884
+ getNextTabbable(domReference)?.focus();
885
+ } else {
886
+ portalContext.beforeOutsideRef.current?.focus();
887
+ }
883
888
  }
884
- }
885
- },
886
- }),
889
+ },
890
+ })
891
+ : null,
887
892
  !isUntrappedTypeableCombobox && renderDismissButton('start'),
888
- children,
893
+ createElement(Fragment, { key: 'children', children }),
889
894
  renderDismissButton('end'),
890
- shouldRenderGuards &&
891
- createElement(FocusGuard, {
892
- 'data-type': 'inside',
893
- ref: mergedAfterGuardRef,
894
- onFocus: (event: FocusEvent) => {
895
- if (modal) {
896
- enqueueFocus(getTabbableElements()[0]);
897
- } else if (
898
- portalContext != null &&
899
- portalContext.preserveTabOrder &&
900
- portalContext.portalNode
901
- ) {
902
- if (closeOnFocusOut) {
903
- preventReturnFocusRef.current = true;
895
+ shouldRenderGuards
896
+ ? createElement(FocusGuard, {
897
+ key: 'guard-inside-after',
898
+ 'data-type': 'inside',
899
+ ref: mergedAfterGuardRef,
900
+ onFocus: (event: FocusEvent) => {
901
+ if (modal) {
902
+ enqueueFocus(getTabbableElements()[0]);
903
+ } else if (
904
+ portalContext != null &&
905
+ portalContext.preserveTabOrder &&
906
+ portalContext.portalNode
907
+ ) {
908
+ if (closeOnFocusOut) {
909
+ preventReturnFocusRef.current = true;
910
+ }
911
+ if (isOutsideEvent(event, portalContext.portalNode)) {
912
+ getPreviousTabbable(domReference)?.focus();
913
+ } else {
914
+ portalContext.afterOutsideRef.current?.focus();
915
+ }
904
916
  }
905
- if (isOutsideEvent(event, portalContext.portalNode)) {
906
- getPreviousTabbable(domReference)?.focus();
907
- } else {
908
- portalContext.afterOutsideRef.current?.focus();
909
- }
910
- }
911
- },
912
- }),
917
+ },
918
+ })
919
+ : null,
913
920
  ];
914
921
  }
@@ -8,6 +8,7 @@ import {
8
8
  createContext,
9
9
  createElement,
10
10
  createPortal,
11
+ Fragment,
11
12
  useContext,
12
13
  useEffect,
13
14
  useMemo,
@@ -51,6 +52,9 @@ export function FocusGuard(
51
52
  },
52
53
  ): OctaneNode {
53
54
  const [role, setRole] = useState<'button' | undefined>(undefined, S('FocusGuard:role'));
55
+ const elementRef = useRef<HTMLSpanElement | null>(null, S('FocusGuard:element'));
56
+ const forwardedRef = props.ref;
57
+ const onFocus = props.onFocus;
54
58
  useModernLayoutEffect(
55
59
  () => {
56
60
  if (isSafari()) {
@@ -60,8 +64,28 @@ export function FocusGuard(
60
64
  [],
61
65
  S('FocusGuard:eff'),
62
66
  );
67
+ useModernLayoutEffect(
68
+ () => {
69
+ const element = elementRef.current;
70
+ if (!element || !onFocus) return;
71
+ const handleFocus = (event: FocusEvent) => onFocus(event as any);
72
+ element.addEventListener('focusin', handleFocus);
73
+ return () => element.removeEventListener('focusin', handleFocus);
74
+ },
75
+ [onFocus],
76
+ S('FocusGuard:focus'),
77
+ );
78
+ const { ref: _ref, onFocus: _onFocus, ...elementProps } = props;
63
79
  return createElement('span', {
64
- ...props,
80
+ ...elementProps,
81
+ ref: (element: HTMLSpanElement | null) => {
82
+ elementRef.current = element;
83
+ if (typeof forwardedRef === 'function') {
84
+ forwardedRef(element);
85
+ } else if (forwardedRef) {
86
+ forwardedRef.current = element;
87
+ }
88
+ },
65
89
  tabIndex: 0,
66
90
  role,
67
91
  'aria-hidden': role ? undefined : true,
@@ -291,40 +315,51 @@ export function FloatingPortal(props: FloatingPortalProps): OctaneNode {
291
315
  return createElement(PortalContext.Provider, {
292
316
  value,
293
317
  children: [
294
- shouldRenderGuards &&
295
- portalNode &&
296
- createElement(FocusGuard, {
297
- 'data-type': 'outside',
298
- ref: beforeOutsideRef,
299
- onFocus: (event: FocusEvent) => {
300
- if (isOutsideEvent(event, portalNode)) {
301
- beforeInsideRef.current?.focus();
302
- } else {
303
- const domReference = focusManagerState ? focusManagerState.domReference : null;
304
- getPreviousTabbable(domReference)?.focus();
305
- }
306
- },
307
- }),
308
- shouldRenderGuards &&
309
- portalNode &&
310
- createElement('span', { 'aria-owns': portalNode.id, style: HIDDEN_OWNER_STYLES }),
311
- portalNode && createPortal(children, portalNode),
312
- shouldRenderGuards &&
313
- portalNode &&
314
- createElement(FocusGuard, {
315
- 'data-type': 'outside',
316
- ref: afterOutsideRef,
317
- onFocus: (event: FocusEvent) => {
318
- if (isOutsideEvent(event, portalNode)) {
319
- afterInsideRef.current?.focus();
320
- } else {
321
- const domReference = focusManagerState ? focusManagerState.domReference : null;
322
- getNextTabbable(domReference)?.focus();
323
- focusManagerState?.closeOnFocusOut &&
324
- focusManagerState?.onOpenChange(false, event, 'focus-out');
325
- }
326
- },
327
- }),
318
+ shouldRenderGuards && portalNode
319
+ ? createElement(FocusGuard, {
320
+ key: 'guard-outside-before',
321
+ 'data-type': 'outside',
322
+ ref: beforeOutsideRef,
323
+ onFocus: (event: FocusEvent) => {
324
+ if (isOutsideEvent(event, portalNode)) {
325
+ beforeInsideRef.current?.focus();
326
+ } else {
327
+ const domReference = focusManagerState ? focusManagerState.domReference : null;
328
+ getPreviousTabbable(domReference)?.focus();
329
+ }
330
+ },
331
+ })
332
+ : null,
333
+ shouldRenderGuards && portalNode
334
+ ? createElement('span', {
335
+ key: 'aria-owns',
336
+ 'aria-owns': portalNode.id,
337
+ style: HIDDEN_OWNER_STYLES,
338
+ })
339
+ : null,
340
+ portalNode
341
+ ? createElement(Fragment, {
342
+ key: 'portal-children',
343
+ children: createPortal(children, portalNode),
344
+ })
345
+ : null,
346
+ shouldRenderGuards && portalNode
347
+ ? createElement(FocusGuard, {
348
+ key: 'guard-outside-after',
349
+ 'data-type': 'outside',
350
+ ref: afterOutsideRef,
351
+ onFocus: (event: FocusEvent) => {
352
+ if (isOutsideEvent(event, portalNode)) {
353
+ afterInsideRef.current?.focus();
354
+ } else {
355
+ const domReference = focusManagerState ? focusManagerState.domReference : null;
356
+ getNextTabbable(domReference)?.focus();
357
+ focusManagerState?.closeOnFocusOut &&
358
+ focusManagerState?.onOpenChange(false, event, 'focus-out');
359
+ }
360
+ },
361
+ })
362
+ : null,
328
363
  ],
329
364
  });
330
365
  }