PricingDocsAcademy
Bluesky ...
Fri, Dec 13, 8:36 AM

repeat item issue (difficult to explain)

  • unicodes

    2 months ago

    I have a component and I repeat this component based on the data fetched by db. It is a sales tool and fetch companies information. For each repeated component I change the status.

    leads:
    - (1 position) apple: status: "new"
    - (2 position) microsoft : status: "new"
    - (3 position) tesla. : status: "new"

    For the second position, I'm changing the status. The status is included in the component "lead", the status it self is a component with variables.

    I'm editing the status of to the lead Microsoft:

    - (1 position) apple : status: "new"
    - (2 position) microsoft : status: "Prospect"
    - (3 position) tesla. : status: "new"

    I'm working on the lead and I'm not saving it because I want to continue after adding the new lead (i'm not refreshing the page).

    Now, without refreshing the page I'm adding a new lead.

    Leads:
    - (1 position) Intel: status "new"
    - (2 position) apple: status: "prospect"
    - (3 position) microsoft : status: "new"
    - (4 position) tesla. : status: "new"

    Adding the new lead means recalling the API Lead loading.

    Where is the issue?
    The API Lead loading fetch the correct information from the DB:
    - (1 position) Intel: status "new"
    - (2 position) apple: status: "new"
    - (3 position) microsoft : status: "prospect"
    - (4 position) tesla. : status: "new"

    but on the repeated item I have:
    - (1 position) Intel: status "new"
    - (2 position) apple: status: "prospect"
    - (3 position) microsoft : status: "new"
    - (4 position) tesla. : status: "new"

    What is happening is that the variable doesn't reset the value as it should because was rendered again the component, but stay with the previous value and stay for the position 2 of the rendered items, even if it should go down on position 3.

    This is happening because on loading of the component I'm not reseting the variables values or is more something that it should be seen from toddle side?
  • Erik Beuschau

    2 months ago

    Could you try adding a repeatKey formula in addition to your repeat formula? https://toddle.dev/docs/repeat-formulas#Optimizing%20with%20the
  • unicodes

    2 months ago

    I have many nested components like: status dropdown component (child) > note component (parend fo status and child of lead) > lead component (parent). I added the repeatKey on the lead only and it refreshed everything even if the id was the same "lead-id from db". Do you recommend to add an ID even for the nested components (childs) or just for parent?
  • refreshing everything means it doesn't keep anymore inputs filled but not saved.
  • Erik Beuschau

    2 months ago

    The repeatKey is useful when there are repeated items that:
    - Swap position
    - Update to a similar state as other items

    It should always improve performance to add a repeatKey, but usually it's not necessary. If you have an id or similar for your repeated items, I suggest you try using that.
    Your issue might not be related to repeatKeys, but it's worth a try ๐Ÿ™‚
  • unicodes

    2 months ago

    Thank you Erik for sharing this. It is new for me repeatKey. It doesn't solve my issue. ๐Ÿ˜•
  • Erik Beuschau

    2 months ago

    Alright :/ Could you share a url where I can debug this? Or potentially invite me for your project (if it's a private project, I need to be part of your org first). Username: god_of_code
  • unicodes

    2 months ago

    I have invited you and will provide you soon credentials to login.
    ๐Ÿ‘1

Stop scrolling. Start building.

toddle is a visual web app builder that rivals custom code โ€” but accessible to your entire team!

Try toddle โ€” it's free!

ยฉ Copyright 2024 toddle. All rights reserved.