Merge pull request #8427 from tchak/fix-autosave-with-submitter

fix(js): fix submitter attributes not recognised by safari
This commit is contained in:
Paul Chavard 2023-01-12 18:05:32 +01:00 committed by GitHub
commit 65e125b4ec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -74,6 +74,12 @@ export class AutosubmitController extends ApplicationController {
const submitter = this.hasSubmitterTarget ? this.submitterTarget : null; const submitter = this.hasSubmitterTarget ? this.submitterTarget : null;
const form = const form =
submitter?.form ?? this.element.closest<HTMLFormElement>('form'); submitter?.form ?? this.element.closest<HTMLFormElement>('form');
form?.requestSubmit(submitter);
// Safari does not support "formaction" attribute on submitter passed to requestSubmit :(
if (submitter && navigator.userAgent.indexOf('Safari') > -1) {
submitter.click();
} else {
form?.requestSubmit(submitter);
}
} }
} }