mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #13059 from overleaf/ii-history-react-submit-create-label-modal-with-enter-key
[web] Submit the label creation modal data by pressing Enter GitOrigin-RevId: 6319a7963daf11422d679d9620e400e6f9069fea
This commit is contained in:
parent
ff4ac0a803
commit
0aefc76f79
2 changed files with 37 additions and 39 deletions
|
@ -40,12 +40,11 @@ function AddLabelModal({ show, setShow, version }: AddLabelModalProps) {
|
|||
addUpdateLabel(label)
|
||||
|
||||
reset()
|
||||
|
||||
// TODO
|
||||
// _handleHistoryUIStateChange()
|
||||
}
|
||||
|
||||
const handleAddLabel = () => {
|
||||
const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => {
|
||||
e.preventDefault()
|
||||
|
||||
runAsync(addLabel(projectId, { comment, version }, signal))
|
||||
.then(() => setShow(false))
|
||||
.catch(console.error)
|
||||
|
@ -68,6 +67,7 @@ function AddLabelModal({ show, setShow, version }: AddLabelModalProps) {
|
|||
<Modal.Header>
|
||||
<Modal.Title>{t('history_add_label')}</Modal.Title>
|
||||
</Modal.Header>
|
||||
<form onSubmit={handleSubmit}>
|
||||
<Modal.Body>
|
||||
{isError && <ModalError error={responseError} />}
|
||||
<FormGroup>
|
||||
|
@ -76,9 +76,9 @@ function AddLabelModal({ show, setShow, version }: AddLabelModalProps) {
|
|||
placeholder={t('history_new_label_name')}
|
||||
required
|
||||
value={comment}
|
||||
onChange={(e: React.ChangeEvent<HTMLInputElement & FormControl>) =>
|
||||
setComment(e.target.value)
|
||||
}
|
||||
onChange={(
|
||||
e: React.ChangeEvent<HTMLInputElement & FormControl>
|
||||
) => setComment(e.target.value)}
|
||||
autoFocus // eslint-disable-line jsx-a11y/no-autofocus
|
||||
/>
|
||||
</FormGroup>
|
||||
|
@ -93,14 +93,14 @@ function AddLabelModal({ show, setShow, version }: AddLabelModalProps) {
|
|||
{t('cancel')}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
type="submit"
|
||||
className="btn btn-primary"
|
||||
disabled={isLoading || !comment.length}
|
||||
onClick={handleAddLabel}
|
||||
>
|
||||
{isLoading ? t('history_adding_label') : t('history_add_label')}
|
||||
</button>
|
||||
</Modal.Footer>
|
||||
</form>
|
||||
</AccessibleModal>
|
||||
)
|
||||
}
|
||||
|
|
|
@ -45,8 +45,6 @@ function Tag({ label, currentUserId, ...props }: TagProps) {
|
|||
}
|
||||
|
||||
reset()
|
||||
|
||||
// TODO _handleHistoryUIStateChange
|
||||
}
|
||||
|
||||
const localDeleteHandler = () => {
|
||||
|
|
Loading…
Reference in a new issue