Skip to content

fix: AI selections broken due to floating-ui focus manager#2527

Merged
nperez0111 merged 4 commits intomainfrom
ai-operations-do-not-apply-to-selection-instead-the-whole-blo-1029
Mar 2, 2026
Merged

fix: AI selections broken due to floating-ui focus manager#2527
nperez0111 merged 4 commits intomainfrom
ai-operations-do-not-apply-to-selection-instead-the-whole-blo-1029

Conversation

@YousefED
Copy link
Collaborator

@YousefED YousefED commented Feb 27, 2026

Summary

Fixes AI operations not applying to the current selection — instead, the whole block was affected. The root cause was the floating-ui focus manager (introduced in #2503) interfering with Prosemirror's mutationobserver.

closes #2525

Rationale

Fix using getInsideElements as suggested here

Changes

  • packages/xl-ai/src/components/AIMenu/AIMenuController.tsx: Added getInsideElements to focusManagerProps to include editor.domElement, preventing mutations to the prosemirror element
  • packages/xl-ai/package.json: Bumped @floating-ui/react from ^0.26.28 to ^0.27.18 (required for stablegetInsideElements support).

Impact

  • Fixes the issue where AI operations (e.g., rewrite, translate) would ignore the user's text selection and apply to the whole block.
  • The @floating-ui/react upgrade is a minor version bump and should be backwards-compatible.

Testing

  • Manually verified that text selection is preserved when the AI menu opens.
  • AI operations now correctly apply to the selected text range.

Screenshots/Video

N/A

Checklist

  • Code follows the project's coding standards.
  • Unit tests covering the new feature have been added.
  • All existing tests pass.
  • The documentation has been updated to reflect the new feature

Additional Notes

Related issues:

@vercel
Copy link

vercel bot commented Feb 27, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
blocknote Ready Ready Preview Mar 2, 2026 8:01am
blocknote-website Ready Ready Preview Mar 2, 2026 8:01am

Request Review

@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 2, 2026

Open in StackBlitz

@blocknote/ariakit

npm i https://pkg.pr.new/@blocknote/ariakit@2527

@blocknote/code-block

npm i https://pkg.pr.new/@blocknote/code-block@2527

@blocknote/core

npm i https://pkg.pr.new/@blocknote/core@2527

@blocknote/mantine

npm i https://pkg.pr.new/@blocknote/mantine@2527

@blocknote/react

npm i https://pkg.pr.new/@blocknote/react@2527

@blocknote/server-util

npm i https://pkg.pr.new/@blocknote/server-util@2527

@blocknote/shadcn

npm i https://pkg.pr.new/@blocknote/shadcn@2527

@blocknote/xl-ai

npm i https://pkg.pr.new/@blocknote/xl-ai@2527

@blocknote/xl-docx-exporter

npm i https://pkg.pr.new/@blocknote/xl-docx-exporter@2527

@blocknote/xl-email-exporter

npm i https://pkg.pr.new/@blocknote/xl-email-exporter@2527

@blocknote/xl-multi-column

npm i https://pkg.pr.new/@blocknote/xl-multi-column@2527

@blocknote/xl-odt-exporter

npm i https://pkg.pr.new/@blocknote/xl-odt-exporter@2527

@blocknote/xl-pdf-exporter

npm i https://pkg.pr.new/@blocknote/xl-pdf-exporter@2527

commit: 8ea8e37

@nperez0111 nperez0111 merged commit 9423a16 into main Mar 2, 2026
7 checks passed
@nperez0111 nperez0111 deleted the ai-operations-do-not-apply-to-selection-instead-the-whole-blo-1029 branch March 2, 2026 08:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AI operations do not apply to selection (instead the whole page)

2 participants