1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-01-03 05:25:52 +00:00

fix(web): pressing the enter key now submits dialogs (#7036)

Dialogs by themselves aren't submitted when pressing the Enter key,
for that we need to add an event handler to the dialog itself.

One approach I tried was to add a form to the dialog. This worked, but
needed a CSS workaround to keep the buttons in the same order.

Tested with some other dialogs as well:

* edit labels; and
* set location.

References:

* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/dialog#handling_the_return_value_from_the_dialog
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#formmethod
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form#method

Fixes #6553
This commit is contained in:
Bheesham Persaud 2024-10-21 20:13:42 -04:00 committed by GitHub
parent 89a88c6603
commit 614244bfae
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 5 deletions

View file

@ -153,11 +153,6 @@ export class OpenDialog extends EventTarget {
input.value = url;
workarea.append(input);
elements.url_input = input;
input.addEventListener('keyup', ({ key }) => {
if (key === 'Enter') {
confirm.click();
}
});
input_id = makeUUID();
label = document.createElement('label');

View file

@ -125,6 +125,12 @@ export function createDialogContainer(id) {
confirm.textContent = 'OK';
buttons.append(confirm);
win.addEventListener('keyup', ({ key }) => {
if (key === 'Enter') {
confirm.click();
}
});
const bend = document.createElement('span');
bend.classList.add('dialog-buttons-end');
buttons.append(bend);