From 7ee9691a8c5b4a4b14de652d30cd8528763dc946 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Sun, 17 Jul 2022 11:06:05 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E5=BF=AB=E7=85=A7=E5=9B=9E=E8=BD=A6?= =?UTF-8?q?=E7=BB=91=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/dialog/index.ts | 4 ++-- app/src/util/history.ts | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/src/dialog/index.ts b/app/src/dialog/index.ts index ff02e57e4..6954e7bdc 100644 --- a/app/src/dialog/index.ts +++ b/app/src/dialog/index.ts @@ -66,9 +66,9 @@ export class Dialog { }); } - public bindInput(inputElement: HTMLInputElement, enterEvent?: () => void) { + public bindInput(inputElement: HTMLInputElement | HTMLTextAreaElement, enterEvent?: () => void) { inputElement.focus(); - inputElement.addEventListener("keydown", (event) => { + inputElement.addEventListener("keydown", (event: KeyboardEvent) => { if (event.isComposing) { event.preventDefault(); return; diff --git a/app/src/util/history.ts b/app/src/util/history.ts index 7232d21e7..fbb89f611 100644 --- a/app/src/util/history.ts +++ b/app/src/util/history.ts @@ -423,6 +423,9 @@ export const openHistory = () => { const textareaElement = genRepoDialog.element.querySelector("textarea"); textareaElement.focus(); const btnsElement = genRepoDialog.element.querySelectorAll(".b3-button"); + genRepoDialog.bindInput(textareaElement, () => { + (btnsElement[1] as HTMLButtonElement).click(); + }); btnsElement[0].addEventListener("click", () => { genRepoDialog.destroy(); }); @@ -475,6 +478,9 @@ export const openHistory = () => { btnsElement[0].addEventListener("click", () => { genTagDialog.destroy(); }); + genTagDialog.bindInput(inputElement, () => { + (btnsElement[1] as HTMLButtonElement).click(); + }); btnsElement[1].addEventListener("click", () => { fetchPost("/api/repo/tagSnapshot", { id: target.parentElement.getAttribute("data-id"),