From ecf2d155df12b4db2769e7f55ee7225c2bf6f04e Mon Sep 17 00:00:00 2001 From: Fynn Feldpausch Date: Thu, 28 Nov 2024 16:15:00 +0100 Subject: [PATCH] fix(core): submit button should not cause a reload in firefox (#611) --- core/src/components/cat-button/cat-button.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/src/components/cat-button/cat-button.tsx b/core/src/components/cat-button/cat-button.tsx index c09e7d16..3e7f1fae 100644 --- a/core/src/components/cat-button/cat-button.tsx +++ b/core/src/components/cat-button/cat-button.tsx @@ -199,10 +199,10 @@ export class CatButton { event.stopImmediatePropagation(); } else if (this.submit) { const form = findClosest('form', this.hostElement); - const event = new SubmitEvent('submit', { submitter: this.button, cancelable: true }); - form?.dispatchEvent(event); - event.stopPropagation(); - event.preventDefault(); + if (form && form instanceof HTMLFormElement) { + // we can't provide a submitter as it is hidden in the shadow DOM + form.requestSubmit(); + } } }