mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-15 06:33:55 +01:00
Prevent adding multiple replies by hitting enter while submitting (#23240)
GitOrigin-RevId: 342aa30f89f3ac0b0b25ab931dd4df1d956aa4a1
This commit is contained in:
committed by
Copybot
parent
cb8f5898af
commit
d9a32a8dca
+17
-3
@@ -1,4 +1,4 @@
|
|||||||
import { memo, useCallback } from 'react'
|
import { memo, useCallback, useState } from 'react'
|
||||||
import { Change, CommentOperation } from '../../../../../types/change'
|
import { Change, CommentOperation } from '../../../../../types/change'
|
||||||
import { ReviewPanelMessage } from './review-panel-message'
|
import { ReviewPanelMessage } from './review-panel-message'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
@@ -38,10 +38,24 @@ export const ReviewPanelCommentContent = memo<{
|
|||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const threads = useThreadsContext()
|
const threads = useThreadsContext()
|
||||||
const permissions = usePermissionsContext()
|
const permissions = usePermissionsContext()
|
||||||
|
const [submitting, setSubmitting] = useState(false)
|
||||||
|
|
||||||
const handleSubmit = useCallback(
|
const handleSubmit = useCallback(
|
||||||
(content, setContent) => onReply?.(content).then(() => setContent('')),
|
(content, setContent) => {
|
||||||
[onReply]
|
if (!onReply || submitting) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
setSubmitting(true)
|
||||||
|
onReply(content)
|
||||||
|
.then(() => {
|
||||||
|
setContent('')
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
setSubmitting(false)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
[onReply, submitting]
|
||||||
)
|
)
|
||||||
|
|
||||||
const { handleChange, handleKeyPress, content } =
|
const { handleChange, handleKeyPress, content } =
|
||||||
|
|||||||
Reference in New Issue
Block a user