BlockNote icon indicating copy to clipboard operation
BlockNote copied to clipboard

fix: Suggestion menu overflow issue

Open matthewlipski opened this issue 1 month ago • 4 comments

Summary

This PR fixes an issue when on initial show, the suggestion menu would not correctly flip vertically if there was no space, and would only flip once the items updated.

This would happen because the GenericPopover responsible for positioning and sizing the suggestion menu would do so based on its initial size. However, the menu fetches and renders its items async, so its initial size is far smaller than when it has all of its items.

To fix this, the GenericPopover's position is re-calculated when the suggestion menu items are updated.

Rationale

The suggestion menu issue is pretty annoying for users and causes bad UX.

Changes

  • Added GenericPopoverContext which holds the return values for FloatingUI hooks in the GenericPopover.
  • Made SuggestionMenuWrapper update ancestor GenericPopover position when after items are updated.
  • Changed autoPlacement middleware to flip (functions same as before, but autoPlacement was inconsistent after this change).

Impact

N/A

Testing

N/A

Screenshots/Video

N/A

Checklist

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

Additional Notes

matthewlipski avatar Jan 15 '26 16:01 matthewlipski