Skip to content

Commit 1f102e1

Browse files
Merge pull request #184 from pneumaticapp/frontend/editor/45330__fix_tagging_in_comment_boxes
45330 frontend [ editor ] Fix tagging in comment boxes
2 parents 533be26 + 7e40314 commit 1f102e1

12 files changed

Lines changed: 45 additions & 11 deletions

File tree

frontend/src/public/components/Field/Field.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ export function Field({
107107
}}
108108
className={styles['rich-editor']}
109109
accountId={accountId as number}
110+
withMentions={false}
110111
/>
111112
);
112113
default:

frontend/src/public/components/RichEditor/__tests__/RichEditor.integration.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ describe('RichEditor integration', () => {
3636

3737
it('contract: ref exposes focus, insertVariable, clearContent, getEditor', () => {
3838
const ref = React.createRef<IRichEditorHandle>();
39-
render(<RichEditor ref={ref} handleChange={() => Promise.resolve('')} />);
39+
render(<RichEditor ref={ref} handleChange={() => Promise.resolve('')} withMentions={false} />);
4040
expect(ref.current).not.toBeNull();
4141
expect(typeof ref.current?.focus).toBe('function');
4242
expect(typeof ref.current?.insertVariable).toBe('function');
@@ -46,7 +46,7 @@ describe('RichEditor integration', () => {
4646

4747
it('contract: handleChange is invoked when parent passes it', () => {
4848
const handleChange = jest.fn().mockResolvedValue('');
49-
render(<RichEditor handleChange={handleChange} />);
49+
render(<RichEditor handleChange={handleChange} withMentions={false} />);
5050
expect(handleChange).not.toHaveBeenCalled();
5151
});
5252
});

frontend/src/public/components/RichEditor/plugins/MentionsPlugin/MentionMenuList.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ function MentionMenuListComponent({
5252
position: 'fixed',
5353
top: rect.bottom + 4,
5454
left: rect.left,
55-
zIndex: 10,
55+
zIndex: 1100,
5656
}}
5757
onMouseDown={(e) => e.preventDefault()}
5858
>

frontend/src/public/components/RichEditor/plugins/MentionsPlugin/MentionsPlugin.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React from 'react';
2-
import { createPortal } from 'react-dom';
32
import { useMentionMenu } from './useMentionMenu';
43
import { MentionMenuList } from './MentionMenuList';
54
import type { MentionsPluginProps } from './types';
@@ -29,5 +28,5 @@ export function MentionsPlugin({ mentions }: MentionsPluginProps): React.ReactEl
2928
/>
3029
);
3130

32-
return createPortal(menuContent, document.body);
31+
return menuContent;
3332
}

frontend/src/public/components/RichEditor/types.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,12 @@ export type TMentionData = {
2020
link?: string;
2121
};
2222

23-
export interface IRichEditorProps {
23+
export interface IRichEditorBaseProps {
2424
isModal?: boolean;
2525
accountId?: number;
26-
mentions?: TMentionData[];
2726
placeholder?: string;
2827
className?: string;
2928
defaultValue?: string;
30-
withMentions?: boolean;
3129
withToolbar?: boolean;
3230
withChecklists?: boolean;
3331
multiline?: boolean;
@@ -46,6 +44,18 @@ export interface IRichEditorProps {
4644
onCancel?(): void;
4745
}
4846

47+
type WithMentionsProps = {
48+
withMentions?: true;
49+
mentions: TMentionData[];
50+
};
51+
52+
type WithoutMentionsProps = {
53+
withMentions: false;
54+
mentions?: never;
55+
};
56+
57+
export type IRichEditorProps = IRichEditorBaseProps & (WithMentionsProps | WithoutMentionsProps);
58+
4959
export interface ILexicalEditorContentProps {
5060
placeholder?: string;
5161
withChecklists?: boolean;

frontend/src/public/components/TaskCard/ReturnModal/ReturnModal.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export function ReturnModal({ isOpen, onClose, onConfirm }: IReturnModalProps) {
3737
return message;
3838
}}
3939
isModal={isModal}
40+
withMentions={false}
4041
/>
4142
</div>
4243

frontend/src/public/components/TemplateEdit/InputWithVariables/InputWithVariables.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export const InputWithVariables: React.FC<IEditorWithVariablesProps> = ({
5555
defaultValue={formattedValue}
5656
handleChange={onChange}
5757
withToolbar={false}
58+
withMentions={false}
5859
multiline={false}
5960
className={classnames(className, styles['input-with-variables'])}
6061
foregroundColor={foregroundColor}

frontend/src/public/components/TemplateEdit/TemplateSettings/TemplateSettings.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ export function TemplateSettings() {
7979
<RichEditor
8080
key={template.id ?? 'new'}
8181
withToolbar={false}
82+
withMentions={false}
8283
placeholder={formatMessage({ id: 'template.placeholder' })}
8384
className={styles['description-editor']}
8485
defaultValue={template.description ?? ''}

frontend/src/public/components/Workflows/WorkflowLog/PopupCommentField/PopupCommentField.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import * as React from 'react';
22
import { useIntl } from 'react-intl';
33

44
import { RichEditor, type IRichEditorHandle } from '../../../RichEditor';
5+
import { type TMentionData } from '../../../RichEditor/types';
56
import { Avatar } from '../../../UI/Avatar';
67
import { IAuthUser } from '../../../../types/redux';
78
import { TUploadedFile } from '../../../../utils/uploadFiles';
@@ -13,13 +14,14 @@ import styles from './PopupCommentField.css';
1314

1415
export interface IPopupCommentFieldProps {
1516
user: IAuthUser;
17+
mentions: TMentionData[];
1618
sendComment({ text, attachments, taskId }: ISendWorkflowLogComment): void;
1719
taskId?: number;
1820
}
1921

2022
export type TPopupCommentFieldProps = IPopupCommentFieldProps;
2123

22-
export function PopupCommentField({ user, sendComment, taskId }: TPopupCommentFieldProps) {
24+
export function PopupCommentField({ user, mentions, sendComment, taskId }: TPopupCommentFieldProps) {
2325
const { formatMessage } = useIntl();
2426
const editorRef = React.useRef<IRichEditorHandle>(null);
2527

@@ -56,6 +58,7 @@ export function PopupCommentField({ user, sendComment, taskId }: TPopupCommentFi
5658
onSubmit={handleSendComment}
5759
className={styles['editor']}
5860
accountId={user.id}
61+
mentions={mentions}
5962
/>
6063
</div>
6164
</div>

frontend/src/public/components/Workflows/WorkflowLog/WorkflowLog.tsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as React from 'react';
2-
import { useEffect } from 'react';
2+
import { useEffect, useMemo } from 'react';
3+
import { useSelector } from 'react-redux';
34
import classnames from 'classnames';
45
import { useIntl } from 'react-intl';
56
import Switch from 'rc-switch';
@@ -41,6 +42,9 @@ import { WorkflowLogRemovedPerformerGroup } from './WorkflowLogEvents/WorkflowLo
4142

4243
import styles from './WorkflowLog.css';
4344
import { IChangeWorkflowLogViewSettingsPayload, ISendWorkflowLogComment } from '../../../redux/workflows/types';
45+
import { getUsers } from '../../../redux/selectors/user';
46+
import { getNotDeletedUsers } from '../../../utils/users';
47+
import { getMentionData } from '../../RichEditor/utils/getMentionData';
4448

4549
export const WorkflowLog = ({
4650
theme,
@@ -69,6 +73,12 @@ export const WorkflowLog = ({
6973
}: IWorkflowLogProps) => {
7074
const { formatMessage } = useIntl();
7175

76+
const users = useSelector(getUsers);
77+
const mentions = useMemo(
78+
() => getMentionData(getNotDeletedUsers(users)),
79+
[users],
80+
);
81+
7282
useEffect(() => {
7383
return () => {
7484
if (onUnmount) {
@@ -213,7 +223,7 @@ export const WorkflowLog = ({
213223

214224
return (
215225
<div className={styles['comment-field']}>
216-
<PopupCommentFieldContainer sendComment={sendComment} taskId={taskId} />
226+
<PopupCommentFieldContainer sendComment={sendComment} taskId={taskId} mentions={mentions} />
217227
</div>
218228
);
219229
};
@@ -270,6 +280,7 @@ export const WorkflowLog = ({
270280
<WorkflowLogTaskCommentContainer
271281
workflowStatus={workflowStatus}
272282
isOnlyAttachmentsShown={isOnlyAttachmentsShown}
283+
mentions={mentions}
273284
{...event}
274285
/>
275286
),

0 commit comments

Comments
 (0)