code.gitea.io/gitea@v1.22.3/web_src/js/features/comp/QuickSubmit.js (about)

     1  export function handleGlobalEnterQuickSubmit(target) {
     2    let form = target.closest('form');
     3    if (form) {
     4      if (!form.checkValidity()) {
     5        form.reportValidity();
     6      } else {
     7        // here use the event to trigger the submit event (instead of calling `submit()` method directly)
     8        // otherwise the `areYouSure` handler won't be executed, then there will be an annoying "confirm to leave" dialog
     9        form.dispatchEvent(new SubmitEvent('submit', {bubbles: true, cancelable: true}));
    10      }
    11      return true;
    12    }
    13    form = target.closest('.ui.form');
    14    if (form) {
    15      form.querySelector('.ui.primary.button')?.click();
    16      return true;
    17    }
    18    return false;
    19  }