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 textMentionsRef = useRef(null);
|
||||
const textInputRef = useRef(null);
|
||||
const [buttonRef, handleButtonRef] = useNestedRef();
|
||||
const [submitButtonRef, handleSubmitButtonRef] = useNestedRef();
|
||||
const [cancelButtonRef, handleCancelButtonRef] = useNestedRef();
|
||||
|
||||
const submit = useCallback(() => {
|
||||
const cleanData = {
|
||||
|
@ -91,12 +92,16 @@ const Edit = React.memo(({ commentId, onClose }) => {
|
|||
[onClose, submit],
|
||||
);
|
||||
|
||||
const handleCancelClick = useCallback(() => {
|
||||
onClose();
|
||||
}, [onClose]);
|
||||
|
||||
const handleClickAwayCancel = useCallback(() => {
|
||||
textInputRef.current.focus();
|
||||
}, []);
|
||||
|
||||
const clickAwayProps = useClickAwayListener(
|
||||
[textFieldRef, buttonRef],
|
||||
[textFieldRef, submitButtonRef, cancelButtonRef],
|
||||
submit,
|
||||
handleClickAwayCancel,
|
||||
);
|
||||
|
@ -152,9 +157,16 @@ const Edit = React.memo(({ commentId, onClose }) => {
|
|||
<Button
|
||||
{...clickAwayProps} // eslint-disable-line react/jsx-props-no-spreading
|
||||
positive
|
||||
ref={handleButtonRef}
|
||||
ref={handleSubmitButtonRef}
|
||||
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>
|
||||
</Form>
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue