mirror of
https://github.com/zen-browser/desktop.git
synced 2026-05-20 03:51:20 +00:00
no-bug: Submit workspace creation form on Enter and cancel on Escape (gh-13549)
Co-authored-by: Zander Otavka <AlexanderOtavka@users.noreply.github.com> Co-authored-by: mr. m <91018726+mr-cheffy@users.noreply.github.com>
This commit is contained in:
@@ -83,6 +83,7 @@
|
||||
& label {
|
||||
max-width: 4rem;
|
||||
margin-left: 8px;
|
||||
color: white;
|
||||
}
|
||||
|
||||
& image {
|
||||
|
||||
@@ -148,6 +148,28 @@ class nsZenWorkspaceCreation extends MozXULElement {
|
||||
this.createButton.disabled = !this.inputName.value.trim();
|
||||
});
|
||||
|
||||
this.inputName.addEventListener("keydown", event => {
|
||||
if (event.key === "Enter") {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
if (!this.createButton.disabled) {
|
||||
this.createButton.doCommand();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Bound on the root so Esc works regardless of which child has focus
|
||||
// (name input, icon picker trigger, profile button, primary button).
|
||||
// Open popups consume Esc before it reaches us, so the emoji/profile
|
||||
// pickers still close as expected.
|
||||
this.addEventListener("keydown", event => {
|
||||
if (event.key === "Escape") {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
this.cancelButton.doCommand();
|
||||
}
|
||||
});
|
||||
|
||||
this.inputIcon.addEventListener("command", this.onIconCommand.bind(this));
|
||||
|
||||
this.profilesPopup = this.querySelector(
|
||||
|
||||
Reference in New Issue
Block a user