Skip to content

Conversation

@matthewlipski
Copy link
Collaborator

Summary

This PR fixes an issue where if the suggestion menu was displayed above the trigger character (when there was not enough space to display it below), and only showed a few items, there would be a large gap between the menu and trigger character. This was because the suggestion menu had a hard-coded minimum height, which wasn't filled when displaying a small number of items.

Also, the positioning has generally been improved to better take advantage of the available screen space.

Rationale

This issue has made the suggestion menu feel janky in some situations.

Changes

  • Removed minimum height being set in SuggestionMenuController Floating UI options size middleware.
  • Replaced flip middleware with autoPlacement. The difference is that autoPlacement always displays the menu on the side that has more space, whereas flip only changes the side when there is not enough available space for the menu.

Impact

N/A

Testing

Updated Notion UI testing doc.

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

@vercel
Copy link

vercel bot commented Dec 4, 2025

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

Project Deployment Preview Updated (UTC)
blocknote Ready Ready Preview Dec 9, 2025 0:39am
blocknote-agent-demo Error Error Dec 9, 2025 0:39am
blocknote-website Ready Ready Preview Dec 9, 2025 0:39am

@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 4, 2025

Open in StackBlitz

@blocknote/ariakit

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/ariakit@2232

@blocknote/code-block

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/code-block@2232

@blocknote/core

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/core@2232

@blocknote/mantine

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/mantine@2232

@blocknote/react

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/react@2232

@blocknote/server-util

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/server-util@2232

@blocknote/shadcn

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/shadcn@2232

@blocknote/xl-ai

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/xl-ai@2232

@blocknote/xl-docx-exporter

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/xl-docx-exporter@2232

@blocknote/xl-email-exporter

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/xl-email-exporter@2232

@blocknote/xl-multi-column

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/xl-multi-column@2232

@blocknote/xl-odt-exporter

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/xl-odt-exporter@2232

@blocknote/xl-pdf-exporter

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/xl-pdf-exporter@2232

commit: c36f639

Object.assign(elements.floating.style, {
maxHeight: `${availableHeight - 10}px`,
});
apply(p) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about this, maybe @nperez0111 can double check when he's back

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, yea I don't like this fix either. Will get back to it to see what we should do here. I think we may just need it to be re-evaluated once the underlying number of items changes

Copy link
Contributor

@nperez0111 nperez0111 Dec 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, I see what @matthewlipski was trying to do here. I think that I would prefer not to keep the fix as it feels like more of a hack than needed.

What is happening here is that the autoplacement middleware (which is very similar to the flip middleware) is trying to find the best spot to put the menu, and is unaware on the first render how large the element actually is, because it has not yet requested the items since they can be async.

To fix this, we would need to introduce something which would allow the child to request that the parent re-calculate it's position when the number of items changes. Like a context of our own for popovers or https://floating-ui.com/docs/FloatingTree

I think we can look into doing this at a later time though, because while the UX is not ideal, I'd prefer correctness in the code we introduce.

@YousefED YousefED requested a review from nperez0111 December 5, 2025 21:11
@nperez0111 nperez0111 merged commit ca26d5c into main Dec 9, 2025
8 of 9 checks passed
@nperez0111 nperez0111 deleted the suggestion-menu-min-height-fix branch December 9, 2025 12:45
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.

4 participants