mirror of
https://github.com/plankanban/planka.git
synced 2025-07-19 05:09:43 +02:00
fix: Add cancel button when editing comment
This commit is contained in:
parent
144731ccb4
commit
5a3a4240c6
1 changed files with 15 additions and 3 deletions
|
@ -45,7 +45,8 @@ const Edit = React.memo(({ commentId, onClose }) => {
|
||||||
const textFieldRef = useRef(null);
|
const textFieldRef = useRef(null);
|
||||||
const textMentionsRef = useRef(null);
|
const textMentionsRef = useRef(null);
|
||||||
const textInputRef = useRef(null);
|
const textInputRef = useRef(null);
|
||||||
const [buttonRef, handleButtonRef] = useNestedRef();
|
const [submitButtonRef, handleSubmitButtonRef] = useNestedRef();
|
||||||
|
const [cancelButtonRef, handleCancelButtonRef] = useNestedRef();
|
||||||
|
|
||||||
const submit = useCallback(() => {
|
const submit = useCallback(() => {
|
||||||
const cleanData = {
|
const cleanData = {
|
||||||
|
@ -91,12 +92,16 @@ const Edit = React.memo(({ commentId, onClose }) => {
|
||||||
[onClose, submit],
|
[onClose, submit],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const handleCancelClick = useCallback(() => {
|
||||||
|
onClose();
|
||||||
|
}, [onClose]);
|
||||||
|
|
||||||
const handleClickAwayCancel = useCallback(() => {
|
const handleClickAwayCancel = useCallback(() => {
|
||||||
textInputRef.current.focus();
|
textInputRef.current.focus();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const clickAwayProps = useClickAwayListener(
|
const clickAwayProps = useClickAwayListener(
|
||||||
[textFieldRef, buttonRef],
|
[textFieldRef, submitButtonRef, cancelButtonRef],
|
||||||
submit,
|
submit,
|
||||||
handleClickAwayCancel,
|
handleClickAwayCancel,
|
||||||
);
|
);
|
||||||
|
@ -152,9 +157,16 @@ const Edit = React.memo(({ commentId, onClose }) => {
|
||||||
<Button
|
<Button
|
||||||
{...clickAwayProps} // eslint-disable-line react/jsx-props-no-spreading
|
{...clickAwayProps} // eslint-disable-line react/jsx-props-no-spreading
|
||||||
positive
|
positive
|
||||||
ref={handleButtonRef}
|
ref={handleSubmitButtonRef}
|
||||||
content={t('action.save')}
|
content={t('action.save')}
|
||||||
/>
|
/>
|
||||||
|
<Button
|
||||||
|
{...clickAwayProps} // eslint-disable-line react/jsx-props-no-spreading
|
||||||
|
ref={handleCancelButtonRef}
|
||||||
|
type="button"
|
||||||
|
content={t('action.cancel')}
|
||||||
|
onClick={handleCancelClick}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</Form>
|
</Form>
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue