Skip to content

Commit 9423a16

Browse files
authored
fix(ai): selections broken due to floating-ui focus manager (#2527)
1 parent 4cee934 commit 9423a16

4 files changed

Lines changed: 67 additions & 32 deletions

File tree

packages/react/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@
6060
"dependencies": {
6161
"@blocknote/core": "0.47.0",
6262
"@emoji-mart/data": "^1.2.1",
63-
"@floating-ui/react": "^0.27.16",
64-
"@floating-ui/utils": "0.2.10",
63+
"@floating-ui/react": "^0.27.18",
64+
"@floating-ui/utils": "^0.2.10",
6565
"@tanstack/react-store": "0.7.7",
6666
"@tiptap/core": "^3.13.0",
6767
"@tiptap/pm": "^3.13.0",

packages/xl-ai/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
"@blocknote/core": "0.47.0",
7575
"@blocknote/mantine": "0.47.0",
7676
"@blocknote/react": "0.47.0",
77-
"@floating-ui/react": "^0.26.28",
77+
"@floating-ui/react": "^0.27.18",
7878
"@handlewithcare/prosemirror-suggest-changes": "^0.1.8",
7979
"@tiptap/core": "^3.13.0",
8080
"ai": "^6.0.5",

packages/xl-ai/src/components/AIMenu/AIMenuController.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,18 @@ export const AIMenuController = (props: {
9595
// see https://floating-ui.com/docs/floatingfocusmanager#page-scrolls-to-top-when-opening-the-floating-element
9696
focusManagerProps: {
9797
disabled: false,
98+
// needed for https://github.com/floating-ui/floating-ui/pull/3202
99+
// (related: https://github.com/mui/base-ui/issues/3950)
100+
getInsideElements: () => {
101+
if (!editor.domElement) {
102+
return [];
103+
}
104+
return [editor.domElement];
105+
},
98106
...props.floatingUIOptions?.focusManagerProps,
99107
},
100108
}) satisfies FloatingUIOptions,
101-
[ai, aiMenuState, blockId, props.floatingUIOptions],
109+
[ai, aiMenuState, blockId, props.floatingUIOptions, editor.domElement],
102110
);
103111

104112
const Component = props.aiMenu || AIMenu;

pnpm-lock.yaml

Lines changed: 55 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)