Fixed XF.Disabler does not trigger event on input being hidden/shown

TickTackk

Well-known member
Affected version
XF 2.2.2
HTML:
<xf:radiorow name="xyz_option_input" value="radio_b"
             label="{{ phrase('xyz_option') }}">
    <xf:option value="radio_a"
               label="{{ phrase('xyz_option.a') }}"
               data-hide="true"
               data-xf-init="disabler"
               data-container=".xyz_option_a" />
    <xf:option value="radio_b"
               label="{{ phrase('xyz_option.b') }}"
               data-hide="true"
               data-xf-init="disabler"
               data-container=".xyz_option_b" />
</xf:radiorow>

<div class="xyz_option_a">
    <xf:codeeditorrow name="xyz_option_a_contents" value="{$item.option_a_contents}"
                      mode="less"
                      class="codeEditor--autoSize"
                      label="{{ phrase('xyz_option_a_editor_name') }}" />
</div>

<div class="xyz_option_b">
    <xf:editorrow name="xyz_option_b_contents"
                  value="{$item.option_b_contents}"
                  attachments="{{ $attachmentData ? $attachmentData.attachments : [] }}"
                  label="{{ phrase('xyz_option_b_editor_name') }}" />
</div>

In the above template code, if the radio value is set to radio_b and then the visitor switches it to radio_a, the <xf:codeditorrow /> will not be initialized because XF.Disabler does not trigger any custom events on the containers (.xyz_option_a and .xyz_option_b) and XF.CodeEditor is specifically listening to these events toggle:shown overlay:showing tab:shown to be triggered on the <xf:codeeditor />.

Changing
JavaScript:
                if (this.options.hide)
                {
                    if (init)
                    {
                        $container.show();
                    }
                    else
                    {
                        var cb = function()
                        {
                            XF.layoutChange();
                            select();
                        };

                        $container.slideDown(speed, cb);
                    }
                    XF.layoutChange();
                }
                else if (!init)
                {
                    select();
                }
            }
            else
            {
                if (this.options.hide)
                {
                    if (init)
                    {
                        $container.hide();
                    }
                    else
                    {
                        $container.slideUp(speed, XF.layoutChange);
                    }
                    XF.layoutChange();
                }
to
JavaScript:
                if (this.options.hide)
                {
                    if (init)
                    {
                        $container.show();
                    }
                    else
                    {
                        var cb = function()
                        {
                            XF.layoutChange();
                            select();
                        };

                        $container.slideDown(speed, cb);
                    }
                    $container.trigger('toggle:shown');
                    XF.layoutChange();
                }
                else if (!init)
                {
                    select();
                }
            }
            else
            {
                if (this.options.hide)
                {
                    if (init)
                    {
                        $container.hide();
                    }
                    else
                    {
                        $container.slideUp(speed, XF.layoutChange);
                    }
                    $container.trigger('toggle:hidden');
                    XF.layoutChange();
                }
in form.js seems to fix the issue.
 
Thank you for reporting this issue, it has now been resolved. We are aiming to include any changes that have been made in a future XF release (2.2.4).

Change log:
Trigger events when toggling the display of disabler containers
There may be a delay before changes are rolled out to the XenForo Community.
 
Top Bottom