2

With LockerService enabled, we are running into an aura:iteration bug where the order is messed up depending on the values of the array. We're unable to find a work around.

In the component we have a table that calculates its values when a input field is blurred.

Step 1 When loaded initially, the table looks fine. Notice the 0 in the input field. Step 1 Step 2 Then I enter in a value, the table still looks fine. Step 2 Step 3 But then I go back and enter 0 again, how it was initially loaded, and the row breaks. The cell at index 13 jumps way ahead. The data in the console looks all in order. Step 3

If I enter any non-0 value, it works fine again.

This is my aura:iteration at the moment:

<aura:iteration items="{!v.data.totals}" var="value" indexVar="totalsRowIndex">
    <span>
        <td class="{! value == 'table-break' ? 'table-break' : 'slds-text-align--right' }">Index: {!totalsRowIndex} : {! value == 'table-break' ? '&nbsp;' : value }</td>
    </span>
</aura:iteration>

The spans were added in desperation since it has fixed things with aura:iteration quirkiness and aura:if components before. For a moment it looked like we fixed it, but it turned out it was just the values we needed to enter to make it break that changed. Before we added the span, we entered other values to make it break.

Do you guys know what might be the issue? It looks like its a lightning bug since it was working before LockerService. Do you guys see any work arounds?

  • Can you provide a sample piece of code and sample data to isolate and reproduce this bug? The information above seems incomplete to be able to find the cause of this issue. – Chirag Bhatia - chirag64 May 3 '17 at 17:44
4

Excerpt from a known issue:

Workaround

Set an empty array before setting the actual array of items. Note: This workaround will rerender the whole array.

cmp.set("v.someListAttribute", [].concat(updatedArray));

or

cmp.set("v.someListAttribute", []); cmp.set("v.someListAttribute",[].concat(updatedArray));

Note: I have found this workaround has a significant impact on performance as the size of your array grows; I will post back if I am able to come up with a better resolution while we wait for Salesforce to implement a long-term fix.

|improve this answer|||||
  • Update: Initially I was intentionally avoiding the span tag resolution mentioned by @joshuadelange as this caused issues with a 3rd party table sort library. In the end though this was a much simpler issue to resolve than whatever is happening behind the scenes in aura and so far we haven't seen the issue recur. – Scott Covert Jun 27 '17 at 10:28
0

I noticed some similar issues prior to version 40. Are all your components at version 40?

|improve this answer|||||

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.