Confirmed XF.SubmitClick is triggered twice

Painbaker

Well-known member
Licensed customer
Affected version
2.3.10
XF.SubmitClick fires twice on a single click:

Code:
XF.SubmitClick = XF.Event.newHandler({
        eventNameSpace: 'XFSubmitClick',
        options: {
            target: null,
            container: null,
            timeout: 500,
            uncheckedValue: '0',
            disable: null,
        },

        input: null,
        form: null,

        init ()
        {
            ...
        },

        click (e)
        {
            const input = this.input
            const form = this.form
            const target = this.options.target
            const container = this.options.container

            if (!input)
            {
                return
            }

            console.log(e.target);
            console.log('handler fired', Date.now());
            ...
        },
    })


Code:
<label class="iconic iconic--toggle" data-xf-click="submit" data-target="/admin.php?.../toggle">
handler fired 1779658769820
<input type="checkbox" name value="1" checked="checked">
handler fired 1779658769821
timeout fired 1779658769821
timeout fired 1779658769822


The handler is triggered for both the label and the checkbox input resulting in two identical AJAX requests

This breaks the toggle functionality for elements using the specified target since duplicate requests cause the backend state to revert to the original value

This can likely be prevented by a simple filter condition

Code:
if (e.target !== this.input)
{
    return;
}
 
Last edited:
Back
Top Bottom