diff --git a/src/Webform.js b/src/Webform.js index 742f2b5db4..6ac03b7d55 100644 --- a/src/Webform.js +++ b/src/Webform.js @@ -786,7 +786,7 @@ export default class Webform extends NestedDataComponent { * Sets the submission value * @param {object|null|undefined} submission - The submission to set. * @param {object|null|undefined} flags - Any flags to apply when setting the submission. - * @return {void} + * @returns {void} */ onSetSubmission(submission, flags = {}) { this.submissionSet = true; @@ -998,7 +998,9 @@ export default class Webform extends NestedDataComponent { "submitButton", (options) => { this.submit(false, options).catch((e) => { - options.instance.loading = false; + if (options?.instance) { + options.instance.loading = false; + } return e !== false && e !== undefined && console.log(e); }); }, diff --git a/src/components/_classes/component/Component.js b/src/components/_classes/component/Component.js index 0aeca4650a..af955a23a5 100644 --- a/src/components/_classes/component/Component.js +++ b/src/components/_classes/component/Component.js @@ -1196,7 +1196,7 @@ export default class Component extends Element { /** * Renders a modal preview template and returns the markup as a string * @param {object|null|undefined} ctx - The rendering context - * @return {string} - The modal preview markup + * @returns {string} - The modal preview markup */ renderModalPreview(ctx) { return this.renderTemplate('modalPreview', ctx || {}); @@ -1272,7 +1272,7 @@ export default class Component extends Element { * Creates the tooltip instance using tippy.js and returns it * @param {HTMLElement} tooltipEl - HTML element to attach the tooltip * @param {object|null|undefined} settings - tippy.js options - * @return {import('tippy.js').Tippy} - tippy.js instance + * @returns {import('tippy.js').Tippy} - tippy.js instance */ createTooltip(tooltipEl, settings = {}) { const tooltipAttribute = tooltipEl.getAttribute('data-tooltip'); diff --git a/src/components/_classes/input/Input.js b/src/components/_classes/input/Input.js index ce7e9c7464..025b457da7 100644 --- a/src/components/_classes/input/Input.js +++ b/src/components/_classes/input/Input.js @@ -269,7 +269,30 @@ export default class Input extends Multivalue { if (key === 13) { event.preventDefault(); event.stopPropagation(); - this.emit('submitButton'); + let submitButton = null; + if (this.root?.everyComponent) { + this.root.everyComponent((component) => { + if ( + component?.component.type === 'button' && + component?.component.action === 'submit' + ) { + submitButton = component; + return false; + } + }); + } + const options = {}; + if (submitButton) { + options.instance = submitButton; + options.component = submitButton.component; + options.noValidate = this.component.state === 'draft'; + options.state = this.component.state || 'submitted'; + submitButton.loading = true; + this.emit('submitButton', options); + } + else { + this.emit('submitButton', options); + } } }); } diff --git a/src/components/form/Form.js b/src/components/form/Form.js index 7ec73f3a2b..f402414fb2 100644 --- a/src/components/form/Form.js +++ b/src/components/form/Form.js @@ -733,7 +733,7 @@ export default class FormComponent extends Component { * Sets the subform value * @param {object|null|undefined} submission - The submission to set. * @param {object|null|undefined} flags - Any flags to apply when setting the submission. - * @return {void} + * @returns {void} */ onSetSubFormValue(submission, flags) { this.subForm.setValue(submission, flags);