Lightning component error handleOnBlur event

I have an iteration on a component with an ui:inputNumber inside, which has an onchange event that calls a server side action. If after i change the value, i click on an input after the onchange is complete it throws me an error:

Uncaught Action failed: ui:inputSmartNumber$controller$handleOnBlur
[Cannot read property ‘indexOf’ of undefined]

I have also tried this with the blur event but the error still persists.

Some code for a preview:


<aura:component controller="c_MyController" implements="force:lightningQuickActionWithoutHeader,flexipage:availableForAllPageTypes,force:hasRecordId" access="global">
    <aura:attribute name="array" type="Object[]"/>
    <aura:iteration items="{!v.array}" var="obj">
         <ui:inputNumber value="{!obj.Number}" change="{!c.callAction}"/>


callAction : function(component, event, helper) {
    var action = component.get("c.myAction");

        var state = response.getState();
        if(state === 'SUCCESS'){
            component.set("v.array", response.getReturnValue());
        }else if (state === "ERROR") {

Server Side Controller:

public static List<MyObject__c> myAction(){
    return [Select Id From MyObject__c];

Edit: I believe that this is happening because of this line : component.set("v.array", response.getReturnValue()); although it shouldn’t. I believe the problem is that the focused element while the onchange event is running is rebuilt. But i have no idea how to workaround this issue.


Source : Link , Question Author : Marco Galvão , Answer Author : Community

Leave a Comment