Skip to content

Commit b3d7407

Browse files
committed
Remove portal
1 parent 87692a3 commit b3d7407

File tree

3 files changed

+51
-56
lines changed

3 files changed

+51
-56
lines changed

packages/twenty-front/src/modules/advanced-text-editor/extensions/slash-command/DefaultSlashCommands.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export const DEFAULT_SLASH_COMMANDS: SlashCommandConfig[] = [
3030
icon: IconPilcrow,
3131
keywords: [msg`paragraph`, msg`text`, msg`p`],
3232
getIsActive: (editor) => editor.isActive('paragraph'),
33-
getIsVisible: (editor) => editor.can().setParagraph?.() ?? true,
33+
getIsVisible: (editor) => editor.can().setParagraph?.() ?? false,
3434
getOnSelect: (editor, range) => () => {
3535
return editor.chain().focus().deleteRange(range).setParagraph().run();
3636
},

packages/twenty-front/src/modules/advanced-text-editor/extensions/slash-command/SlashCommand.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { i18n } from '@lingui/core';
22
import { Extension, type Editor, type Range } from '@tiptap/core';
33
import Suggestion, { type SuggestionOptions } from '@tiptap/suggestion';
4+
import { type IconComponent } from 'twenty-ui/display';
45

56
import {
67
DEFAULT_SLASH_COMMANDS,
78
type SlashCommandConfig,
89
} from '@/advanced-text-editor/extensions/slash-command/DefaultSlashCommands';
910
import { SlashCommandRenderer } from '@/advanced-text-editor/extensions/slash-command/SlashCommandRenderer';
10-
import { type IconComponent } from 'twenty-ui/display';
1111

1212
export type SlashCommandItem = {
1313
id: string;

packages/twenty-front/src/modules/advanced-text-editor/extensions/slash-command/SlashCommandMenu.tsx

Lines changed: 49 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
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';
61
import { ThemeProvider } from '@emotion/react';
72
import {
83
autoUpdate,
@@ -22,10 +17,15 @@ import {
2217
useRef,
2318
useState,
2419
} from 'react';
25-
import { createPortal } from 'react-dom';
2620
import { MenuItemSuggestion } from 'twenty-ui/navigation';
2721
import { 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+
2929
export 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

Comments
 (0)