Skip to content

armgit / plane

Public Imported from GitHub
0

πŸ”₯πŸ”₯πŸ”₯ Open-source Jira, Linear, Monday, and ClickUp alternative. Plane is a modern project management platform to manage tasks, sprints, docs, and triage.

[WIKI-705] regression: mentions dropdown selection across editors #7901

Aaryan Khandelwal269fc0d9e063
diff --git a/packages/editor/src/core/extensions/mentions/utils.ts b/packages/editor/src/core/extensions/mentions/utils.ts
index 24e9957a37..91f713fd7c 100644
--- a/packages/editor/src/core/extensions/mentions/utils.ts
+++ b/packages/editor/src/core/extensions/mentions/utils.ts
@@ -11,49 +11,44 @@ import { TMentionHandler } from "@/types";
import { MentionsListDropdown, MentionsListDropdownProps } from "./mentions-list-dropdown";
export const renderMentionsDropdown =
- (props: Pick<TMentionHandler, "searchCallback">): SuggestionOptions["render"] =>
- // @ts-expect-error - Tiptap types are incorrect
+ (args: Pick<TMentionHandler, "searchCallback">): SuggestionOptions["render"] =>
() => {
- const { searchCallback } = props;
+ const { searchCallback } = args;
let component: ReactRenderer<CommandListInstance, MentionsListDropdownProps> | null = null;
return {
- onStart: ({ clientRect, editor }) => {
+ onStart: (props) => {
if (!searchCallback) return;
- if (!clientRect) return;
+ if (!props.clientRect) return;
component = new ReactRenderer<CommandListInstance, MentionsListDropdownProps>(MentionsListDropdown, {
props: {
...props,
searchCallback,
},
- editor: editor,
+ editor: props.editor,
});
- editor.commands.addActiveDropbarExtension(CORE_EXTENSIONS.MENTION);
+ props.editor.commands.addActiveDropbarExtension(CORE_EXTENSIONS.MENTION);
const element = component.element as HTMLElement;
element.style.position = "absolute";
+ element.style.zIndex = "100";
document.body.appendChild(element);
- updateFloatingUIFloaterPosition(editor, element);
+ updateFloatingUIFloaterPosition(props.editor, element);
},
- onUpdate: ({ clientRect, editor }) => {
+ onUpdate: (props) => {
component?.updateProps(props);
- if (!clientRect) return;
+ if (!props.clientRect) return;
if (component?.element) {
- updateFloatingUIFloaterPosition(editor, component?.element as HTMLElement);
+ updateFloatingUIFloaterPosition(props.editor, component?.element as HTMLElement);
}
},
onKeyDown: ({ event }) => {
if (event.key === "Escape") {
component?.destroy();
+ component = null;
return true;
}
- const navigationKeys = ["ArrowUp", "ArrowDown", "Enter"];
-
- if (navigationKeys.includes(event.key)) {
- event?.stopPropagation();
- return component?.ref?.onKeyDown({ event });
- }
- return component?.ref?.onKeyDown({ event });
+ return component?.ref?.onKeyDown({ event }) ?? false;
},
onExit: ({ editor }) => {
editor.commands.removeActiveDropbarExtension(CORE_EXTENSIONS.MENTION);
diff --git a/packages/editor/src/core/extensions/slash-commands/command-menu.tsx b/packages/editor/src/core/extensions/slash-commands/command-menu.tsx
index 9d85266f2b..56ad688bc1 100644
--- a/packages/editor/src/core/extensions/slash-commands/command-menu.tsx
+++ b/packages/editor/src/core/extensions/slash-commands/command-menu.tsx
@@ -32,9 +32,8 @@ export const SlashCommandsMenu = forwardRef((props: SlashCommandsMenuProps, ref)
);
// handle arrow key navigation
useEffect(() => {
- const navigationKeys = ["ArrowUp", "ArrowDown", "Enter"];
const onKeyDown = (e: KeyboardEvent) => {
- if (navigationKeys.includes(e.key)) {
+ if (DROPDOWN_NAVIGATION_KEYS.includes(e.key)) {
e.preventDefault();
const currentSection = selectedIndex.section;
const currentItem = selectedIndex.item;