mirror of
https://github.com/docusealco/docuseal
synced 2026-11-04 06:42:32 -05:00
19 lines
638 B
JavaScript
19 lines
638 B
JavaScript
export default class extends HTMLElement {
|
|
connectedCallback () {
|
|
document.addEventListener('turbo:submit-end', this.onSubmit)
|
|
}
|
|
|
|
disconnectedCallback () {
|
|
document.removeEventListener('turbo:submit-end', this.onSubmit)
|
|
}
|
|
|
|
onSubmit = (e) => {
|
|
if (!e.detail.success || e.detail.fetchResponse?.redirected) return
|
|
if (e.detail.formSubmission?.formElement?.method === 'get') return
|
|
if (this.dataset.closeAfterSubmit === 'false') return
|
|
if (e.detail.formSubmission?.formElement?.dataset?.closeOnSubmit === 'false') return
|
|
|
|
window.webkit?.messageHandlers?.modal?.postMessage({ action: 'submitted' })
|
|
}
|
|
}
|