giteabot backport / giteabot (push) Canceled after 0s
giteabot / giteabot (push) Canceled after 0s
release-nightly / nightly-binary (push) Canceled after 0s
release-nightly / nightly-container (push) Canceled after 0s
cache-seeder / gobuild (push) Canceled after 0s
cache-seeder / lint (bindata, lint-backend) (push) Canceled after 0s
release-nightly-snapcraft / build-and-publish (push) Canceled after 0s
Includes direct password setup links in registration emails. Assisted-by: Codex:GPT-5
26 lines
1.1 KiB
TypeScript
26 lines
1.1 KiB
TypeScript
import {querySingleVisibleElem} from '../../utils/dom.ts';
|
|
|
|
export function handleGlobalEnterQuickSubmit(target: HTMLElement) {
|
|
let form = target.closest('form');
|
|
if (form) {
|
|
if (!form.checkValidity()) {
|
|
form.reportValidity();
|
|
} else {
|
|
// here use the event to trigger the submit event (instead of calling `submit()` method directly)
|
|
// otherwise the `areYouSure` handler won't be executed, then there will be an annoying "confirm to leave" dialog
|
|
form.dispatchEvent(new SubmitEvent('submit', {bubbles: true, cancelable: true}));
|
|
}
|
|
return true;
|
|
}
|
|
form = target.closest('.ui.form');
|
|
if (form) {
|
|
// A form should only have at most one "primary" button to do quick-submit.
|
|
// Here we don't use a special class to mark the primary button,
|
|
// because there could be a lot of forms with a primary button, the quick submit should work out-of-box,
|
|
// but not keeps asking developers to add that special class again and again (it could be forgotten easily)
|
|
querySingleVisibleElem<HTMLButtonElement>(form, '.ui.primary.button')?.click();
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|