Skip to content

Commit f1116a4

Browse files
committed
Modals trigger submit on Enter key, bug fix
1 parent 14f0684 commit f1116a4

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/keybinds/keybinds.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ try {
1212
const isTyping = document.activeElement.matches("input, textarea");
1313
if (e.ctrlKey) {
1414
if (e.key == "Enter" && !anyDialogOpen) {
15-
document.getElementById("submit-button").click();
15+
document.getElementById("submit-button")?.click();
1616
}
1717
if (e.key == "," && !anyDialogOpen) {
1818
ui.view("settings");
@@ -36,6 +36,8 @@ try {
3636
if (e.key == "R" && !anyDialogOpen && !isTyping) {
3737
themes.resetTheme();
3838
}
39+
} else if (e.key == "Enter" && anyDialogOpen) {
40+
document.querySelector('dialog[open] .submit-button')?.click();
3941
}
4042
});
4143
} catch (error) {

src/modules/ui.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export function modal(options) {
7070
var btnElement = new Element("button", button.text, {
7171
click: () => {
7272
if (button.onclick) {
73-
const inputValue = (dialog.querySelectorAll(".dialog-input").length > 0) ? [...dialog.querySelectorAll(".dialog-input")].map(dialogInput => {
73+
const inputValue = (dialog.querySelectorAll(".dialog-input").length > 1) ? [...dialog.querySelectorAll(".dialog-input")].map(dialogInput => {
7474
return dialogInput.value;
7575
}) : (dialog.querySelector(".dialog-input") ? dialog.querySelector(".dialog-input").value : null);
7676
button.onclick(inputValue);

0 commit comments

Comments
 (0)