Skip to content

feat(slash): refactor DefaultSlashMenu with Floating UI and createPortal#126

Merged
Innei merged 5 commits intomasterfrom
feat/slash-menu-floating-ui
Mar 10, 2026
Merged

feat(slash): refactor DefaultSlashMenu with Floating UI and createPortal#126
Innei merged 5 commits intomasterfrom
feat/slash-menu-floating-ui

Conversation

@Innei
Copy link
Member

@Innei Innei commented Mar 9, 2026

Summary

  • Refactor DefaultSlashMenu to use @floating-ui/react useFloating hook with flip()/shift()/offset() middleware, replacing manual positioning for auto-flip support
  • Portal menu to #lobe-ui-theme-app via createPortal to escape stacking context (z-index) limitations
  • Add placement prop (top/bottom) to force menu direction, skipping auto-flip detection
  • Add getPopupContainer prop for custom scroll container portal target and scroll event listening
  • Fix antd Menu CSS issues: text truncation in ant-menu-title-content-with-extra, missing ant-menu-item-active background
  • Expose slashPlacement and getPopupContainer through top-level Editor component props

Test plan

  • Verify slash menu auto-flips when insufficient space above cursor
  • Verify slashPlacement="bottom" forces downward display
  • Verify menu escapes stacking context via portal
  • Verify menu items display full text without truncation
  • Verify active item highlight on keyboard navigation
  • Verify getPopupContainer scroll event triggers position update

…createPortal

- Replace antd Dropdown with @floating-ui/react useFloating hook for auto-flip positioning
- Portal to #lobe-ui-theme-app to escape stacking context issues
- Add placement prop to force top/bottom direction, skipping auto-flip
- Add getPopupContainer prop for custom scroll container support
- Fix antd Menu CSS issues (text truncation, active state highlight)
- Expose slashPlacement and getPopupContainer through Editor component
@vercel
Copy link

vercel bot commented Mar 9, 2026

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

Project Deployment Actions Updated (UTC)
lobe-editor Ready Ready Preview, Comment Mar 10, 2026 10:05am

Request Review

@lobehubbot
Copy link
Member

👍 @Innei


Thank you for raising your pull request and contributing to our Community
Please make sure you have followed our contributing guidelines. We will review it as soon as possible.
If you encounter any problems, please feel free to connect with us.
非常感谢您提出拉取请求并为我们的社区做出贡献,请确保您已经遵循了我们的贡献指南,我们会尽快审查它。
如果您遇到任何问题,请随时与我们联系。

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Sorry @Innei, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 9, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@lobehub/editor@126

commit: 8658e48

…dropdown style

- Pass getRect function through position for live cursor tracking
- Use ref-based virtual reference so getBoundingClientRect returns fresh coords
- Replace whileElementsMounted with manual scroll listener (capture phase)
- Align popup/item styles with @lobehub/ui Menu sharedStyle
- Override antd Menu defaults for padding, color, background, item width
Innei added 2 commits March 10, 2026 17:23
- Force position recalculation via rAF after reference is set
- Close menu on plugin unmount to prevent orphaned portal
- Skip rendering when no visible items (only dividers or empty)
@Innei Innei merged commit f19bfa0 into master Mar 10, 2026
4 of 6 checks passed
@Innei Innei deleted the feat/slash-menu-floating-ui branch March 10, 2026 09:28
@lobehubbot
Copy link
Member

❤️ Great PR @Innei ❤️


The growth of project is inseparable from user feedback and contribution, thanks for your contribution!
项目的成长离不开用户反馈和贡献,感谢您的贡献!

@lobehubbot
Copy link
Member

🎉 This PR is included in version 4.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants