diff --git a/client/src/components/comments/Comments/Add.module.scss b/client/src/components/comments/Comments/Add.module.scss index f05d66c5..36521cb7 100644 --- a/client/src/components/comments/Comments/Add.module.scss +++ b/client/src/components/comments/Comments/Add.module.scss @@ -20,7 +20,6 @@ margin-bottom: 8px !important; textarea { - background: #fff; border: 1px solid rgba(9, 30, 66, 0.13); border-radius: 3px; box-sizing: border-box; diff --git a/client/src/components/comments/Comments/Edit.jsx b/client/src/components/comments/Comments/Edit.jsx index 6193afea..aae855b3 100755 --- a/client/src/components/comments/Comments/Edit.jsx +++ b/client/src/components/comments/Comments/Edit.jsx @@ -4,12 +4,12 @@ */ import { dequal } from 'dequal'; -import React, { useCallback, useEffect, useMemo } from 'react'; +import React, { useCallback, useEffect, useMemo, useRef } from 'react'; import PropTypes from 'prop-types'; import { useDispatch, useSelector } from 'react-redux'; import { useTranslation } from 'react-i18next'; -import TextareaAutosize from 'react-textarea-autosize'; -import { Button, Form, TextArea } from 'semantic-ui-react'; +import { Mention, MentionsInput } from 'react-mentions'; +import { Button, Form } from 'semantic-ui-react'; import { useClickAwayListener } from '../../../lib/hooks'; import selectors from '../../../selectors'; @@ -17,6 +17,7 @@ import entryActions from '../../../entry-actions'; import { useForm, useNestedRef } from '../../../hooks'; import { focusEnd } from '../../../utils/element-helpers'; import { isModifierKeyPressed } from '../../../utils/event-helpers'; +import UserAvatar from '../../users/UserAvatar'; import styles from './Edit.module.scss'; @@ -24,6 +25,7 @@ const Edit = React.memo(({ commentId, onClose }) => { const selectCommentById = useMemo(() => selectors.makeSelectCommentById(), []); const comment = useSelector((state) => selectCommentById(state, commentId)); + const boardMemberships = useSelector(selectors.selectMembershipsForCurrentBoard); const dispatch = useDispatch(); const [t] = useTranslation(); @@ -35,12 +37,13 @@ const Edit = React.memo(({ commentId, onClose }) => { [comment.text], ); - const [data, handleFieldChange] = useForm(() => ({ + const [data, , setData] = useForm(() => ({ text: '', ...defaultData, })); - const [textFieldRef, handleTextFieldRef] = useNestedRef(); + const mentionsInputRef = useRef(null); + const textFieldRef = useRef(null); const [buttonRef, handleButtonRef] = useNestedRef(); const submit = useCallback(() => { @@ -60,6 +63,15 @@ const Edit = React.memo(({ commentId, onClose }) => { submit(); }, [submit]); + const handleFieldChange = useCallback( + (_, text) => { + setData({ + text, + }); + }, + [setData], + ); + const handleFieldKeyDown = useCallback( (event) => { if (event.key === 'Enter') { @@ -83,25 +95,53 @@ const Edit = React.memo(({ commentId, onClose }) => { handleClickAwayCancel, ); + const suggestionRenderer = useCallback( + (entry, _, highlightedDisplay) => ( +