-
Notifications
You must be signed in to change notification settings - Fork 4.7k
fix : slash menu overflow causing page scroll #16303
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Welcome!
Hello there, congrats on your first PR! We're excited to have you contributing to this project. |
Greptile OverviewGreptile SummaryFixed slash menu overflow issue by adding Floating UI's Key changes:
Confidence Score: 4/5
Important Files ChangedFile Analysis
Sequence DiagramsequenceDiagram
participant User
participant Editor as Rich Text Editor
participant SlashMenu as CustomSlashMenu
participant FloatingUI as @floating-ui/react
participant DOM as Document Body
User->>Editor: Types "/" command
Editor->>SlashMenu: Render with items
SlashMenu->>FloatingUI: useFloating({placement: 'bottom-start'})
FloatingUI->>FloatingUI: Calculate available space
alt Sufficient space below
FloatingUI->>FloatingUI: flip() keeps bottom placement
FloatingUI->>FloatingUI: offset() returns 0
FloatingUI-->>SlashMenu: Position below with 0 offset
else Insufficient space below
FloatingUI->>FloatingUI: flip() changes to top placement
FloatingUI->>FloatingUI: offset() returns 50px
FloatingUI-->>SlashMenu: Position above with 50px offset
end
SlashMenu->>DOM: createPortal(menu, document.body)
DOM-->>User: Display menu in viewport
Note over SlashMenu,FloatingUI: autoUpdate tracks position changes
User->>SlashMenu: Scrolls or resizes
FloatingUI->>FloatingUI: Recalculate position
FloatingUI-->>SlashMenu: Update floatingStyles
SlashMenu->>DOM: Re-render at new position
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 file reviewed, no comments
|
🚀 Preview Environment Ready! Your preview environment is available at: http://bore.pub:48347 This environment will automatically shut down when the PR is closed or after 5 hours. |
etiennejouan
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your contribution. It works fine, nice job ! 👏
During testing, I wondered if we could have a better logic for the offset. If we open slash menu on a heading block, slash menu overlaps with cursor and text.
I'll check for dynamic solution before approving. If you find one, do not hesitate to commit. It's nitpick, if we don't find anything, we'll merge as is.
Issue : #15794
Context
As shown in the linked issue, slash menu dropdown for rich text editor at bottom of notes editor screen extended beyond the page container, causing main page to scroll.
Changes Made
Added floating UI's
flip()middleware to the component inCustomSlashMenu.tsxso that the menu automatically flips upward when detecting not enough space for dropdown. This prevents overflow beyond the page container.Additionally, added offset to menu when flipping up to prevent overlapping of the current line / caret.
Results
testing.mov