0

I have a ui:inputCheckbox:

<ui:inputCheckbox value="{!v.bool}" change="{!c.toggle}" />

Even if I remove the change attribute, when I click on the checkbox (note: it's a toggle, not sure if that matters) the toggle will very briefly, for less than a second appear as active and will then immediately jump back to inactive (as defined by the bool attribute).

Since the bool attribute is never changing from false I would expect the checkbox to not jump between the inactive and active states when clicked.

Is there some way to enforce this as I think the value jumping like that does not look good.

Component:

<aura:attribute name="valueToSetBool" type="String" default="inactive" />
<aura:handler name="change" value="{!v.record.socialsuite__Status__c}" action="{!c.updater}"/>
<aura:attribute name="bool" type="Boolean" default="false" />
<div class="slds-grid">
    <div class="slds-size_1-of-8 slds-row">
        <div class="slds-form-element">
            <label class="slds-checkbox_toggle slds-grid">
                <span class="slds-form-element__label slds-m-bottom_none slds-m-left_x-small">Active:</span>
                <ui:inputCheckbox value="{!v.bool}"/>
                <span id="toggle-desc" class="slds-checkbox_faux_container" aria-live="assertive">
                    <span class="slds-checkbox_faux"></span>
                    <span class="slds-checkbox_on">Active</span>
                    <span class="slds-checkbox_off">Inactive</span>
                </span>
            </label>
        </div>
    </div>
</div>

Controller:

updater : function(component) {
    component.set("v.bool", false);
}
  • By default, there shouldn't be any input lag. I tested just the code you have here, didn't see a flicker. We'll need to see a Short, Self Contained, Correct (Compilable), Example. – sfdcfox Jan 29 '18 at 8:02
  • @sfdcfox I've added it, I guess this is a bit of an XY problem, what I'm trying to do is bind the checkbox to an attribute that is of type string, I can do stringAttr == 'textIWantToDisplayAsActive' but that doesn't bind the variable. So this is why I have this 'updater' controller function, as a kind of fake binding for my real attribute to the booleanAttribute. It's basically just if attr = 'text`' attrBool = true, if attr = 'text2' attrBool = false – Aequitas Jan 29 '18 at 22:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.