1- import { type SlashCommandItem } from '@/advanced-text-editor/extensions/slash-command/SlashCommand' ;
2- import { RootStackingContextZIndices } from '@/ui/layout/constants/RootStackingContextZIndices' ;
3- import { DropdownContent } from '@/ui/layout/dropdown/components/DropdownContent' ;
4- import { DropdownMenuItemsContainer } from '@/ui/layout/dropdown/components/DropdownMenuItemsContainer' ;
5- import { OverlayContainer } from '@/ui/layout/overlay/components/OverlayContainer' ;
61import { ThemeProvider } from '@emotion/react' ;
72import {
83 autoUpdate ,
@@ -22,10 +17,15 @@ import {
2217 useRef ,
2318 useState ,
2419} from 'react' ;
25- import { createPortal } from 'react-dom' ;
2620import { MenuItemSuggestion } from 'twenty-ui/navigation' ;
2721import { THEME_DARK , THEME_LIGHT } from 'twenty-ui/theme' ;
2822
23+ import { type SlashCommandItem } from '@/advanced-text-editor/extensions/slash-command/SlashCommand' ;
24+ import { RootStackingContextZIndices } from '@/ui/layout/constants/RootStackingContextZIndices' ;
25+ import { DropdownContent } from '@/ui/layout/dropdown/components/DropdownContent' ;
26+ import { DropdownMenuItemsContainer } from '@/ui/layout/dropdown/components/DropdownMenuItemsContainer' ;
27+ import { OverlayContainer } from '@/ui/layout/overlay/components/OverlayContainer' ;
28+
2929export type SlashCommandMenuProps = {
3030 items : SlashCommandItem [ ] ;
3131 onSelect : ( item : SlashCommandItem ) => void ;
@@ -172,54 +172,49 @@ export const SlashCommandMenu = forwardRef<unknown, SlashCommandMenuProps>(
172172 } , [ selectedIndex ] ) ;
173173
174174 return (
175- < >
176- { createPortal (
177- < ThemeProvider theme = { theme } >
178- < motion . div
179- initial = { { opacity : 0 } }
180- animate = { { opacity : 1 } }
181- transition = { { duration : 0.1 } }
182- data-slash-command-menu
183- >
184- < OverlayContainer
185- ref = { refs . setFloating }
186- style = { {
187- ...floatingStyles ,
188- zIndex : RootStackingContextZIndices . DropdownPortalAboveModal ,
189- } }
190- >
191- < DropdownContent ref = { commandListContainerRef } >
192- < DropdownMenuItemsContainer hasMaxHeight >
193- { items . map ( ( item , index ) => {
194- const isSelected = index === selectedIndex ;
195-
196- return (
197- < div
198- key = { item . id }
199- ref = { isSelected ? activeCommandRef : null }
200- onMouseDown = { ( e ) => {
201- e . preventDefault ( ) ;
202- } }
203- >
204- < MenuItemSuggestion
205- LeftIcon = { item . icon }
206- text = { item . title }
207- selected = { isSelected }
208- onClick = { ( ) => {
209- onSelect ( item ) ;
210- } }
211- />
212- </ div >
213- ) ;
214- } ) }
215- </ DropdownMenuItemsContainer >
216- </ DropdownContent >
217- </ OverlayContainer >
218- </ motion . div >
219- </ ThemeProvider > ,
220- document . body ,
221- ) }
222- </ >
175+ < ThemeProvider theme = { theme } >
176+ < motion . div
177+ initial = { { opacity : 0 } }
178+ animate = { { opacity : 1 } }
179+ transition = { { duration : 0.1 } }
180+ data-slash-command-menu
181+ >
182+ < OverlayContainer
183+ ref = { refs . setFloating }
184+ style = { {
185+ ...floatingStyles ,
186+ zIndex : RootStackingContextZIndices . DropdownPortalAboveModal ,
187+ } }
188+ >
189+ < DropdownContent ref = { commandListContainerRef } >
190+ < DropdownMenuItemsContainer hasMaxHeight >
191+ { items . map ( ( item , index ) => {
192+ const isSelected = index === selectedIndex ;
193+
194+ return (
195+ < div
196+ key = { item . id }
197+ ref = { isSelected ? activeCommandRef : null }
198+ onMouseDown = { ( e ) => {
199+ e . preventDefault ( ) ;
200+ } }
201+ >
202+ < MenuItemSuggestion
203+ LeftIcon = { item . icon }
204+ text = { item . title }
205+ selected = { isSelected }
206+ onClick = { ( ) => {
207+ onSelect ( item ) ;
208+ } }
209+ />
210+ </ div >
211+ ) ;
212+ } ) }
213+ </ DropdownMenuItemsContainer >
214+ </ DropdownContent >
215+ </ OverlayContainer >
216+ </ motion . div >
217+ </ ThemeProvider >
223218 ) ;
224219 } ,
225220) ;
0 commit comments