From f971a42e7d21aaad6bc6e8ba14951d83fb52e698 Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Thu, 12 Jan 2023 16:15:27 +0100 Subject: [PATCH] fix(js): fix submitter attributes not recognised by safari --- app/javascript/controllers/autosubmit_controller.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/javascript/controllers/autosubmit_controller.ts b/app/javascript/controllers/autosubmit_controller.ts index 848a3682a..7e3ec78e1 100644 --- a/app/javascript/controllers/autosubmit_controller.ts +++ b/app/javascript/controllers/autosubmit_controller.ts @@ -74,6 +74,12 @@ export class AutosubmitController extends ApplicationController { const submitter = this.hasSubmitterTarget ? this.submitterTarget : null; const form = submitter?.form ?? this.element.closest('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); + } } }