PricingBlog

Repeat item within a component in a repeat item is getting the wrong attribute

  • victoruxui-1237970971009486970

    Victor Giron

    1 year ago

    Hey guys! I'm having this issue:

    I have a table in the page, within each row I have a component called dropdown-status, which receives the statusid from the row.

    Inside the component I have a list of statuses coming from an API call within the component. I want to mark the selected status based on the attribute "statusid" I'm passing from the outside table.

    When I test it inside the component it works, but when I test it from the outside table all the components of the rows are receiving the first-item statusid instead of each row's statusid.
  • gazinhio-1238083518815408128

    gazinhio

    1 year ago

    I'm doing something similar for tax rates, the difference from what I can see you're doing to what I'm doing, is that I call the API for the component list from outside, so I only get it once, and then assign that list into the component with a "list" attribute to work with. I then do the same as you to assign the selected status into the component. Seems to work.
  • gazinhio-1238083875767586867

    gazinhio

    1 year ago

    Just out of interest, what's the app your building? Is it for a client or are you building a SaaS?
  • victoruxui-1238091214134448149

    Victor Giron

    1 year ago

    @ I tried that approach as well but it has the same result, it's just passing the first item statusid to all the instances of the status component.

    I'm recreating an app for my client that I currently have in Weweb. I really want to migrate from Weweb to Toddle, it's a logistics internal app
  • gazinhio-1238091821121540116

    gazinhio

    1 year ago

    OK, let me have a look and see if I'm doing something different with mine. If it's a bit longer of an explain, I'll do a Loom.
  • gazinhio-1238097559071887401

    gazinhio

    1 year ago

    It's been a while so had to refresh myself, dunno if it's best way of doing it but I'll do a Loom and put the link here.
    🙌1
  • lucasg-1238131804268138497

    Lucas G

    1 year ago

    Would it be ok if I took a look at the project or the component? Hard to say but I’d start with the data going into into the repeated row and go from there
  • victoruxui-1238157143400513678

    Victor Giron

    1 year ago

    Of course! You want me to show you the flow in detail or want me to invite you to the project?
  • lucasg-1238157548167757875

    Lucas G

    1 year ago

    You can just dm me the link
  • victoruxui-1238159607382282310

    Victor Giron

    1 year ago

  • in the popover I added next to the labels the current id passing, as you'll see it's passing the first row status id
  • to every instance of the component
  • gazinhio-1238162861923237918

    gazinhio

    1 year ago

    Would you be ok if I created a new branch and just tried something?
  • lucasg-1238167834425692201

    Lucas G

    1 year ago

    We can't create branches unless we're part of the project I don't think
  • I just opened it and the popovers seem broken to me
  • 1238168197597888615-image.png
  • Haven't looked around yet, that's just how it looks on load
  • victoruxui-1238168338069459015

    Victor Giron

    1 year ago

    you can clone it
  • lucasg-1238168359300763699

    Lucas G

    1 year ago

    They seem to be piled up on the corner
  • gazinhio-1238168561537515662

    gazinhio

    1 year ago

    It works in the app ok though. Just spotted a few things that might be causing it but wanna see if I can solve it before.
    🙌1
  • victoruxui-1238168623651229767

    Victor Giron

    1 year ago

    Yeah I think is a rendering thing but when you work on it or preview it, would work normal
  • lucasg-1238168685500305499

    Lucas G

    1 year ago

    Ok just wanted ot make sure lol
    🙌1
  • gazinhio-1238168901792305223

    gazinhio

    1 year ago

    I've cloned it, I'll see if what I think is wrong, actually is
    🔥1
  • victoruxui-1238168985955078256

    Victor Giron

    1 year ago

    Thanks a lot guys!
  • lucasg-1238176677293719692

    Lucas G

    1 year ago

    @Victor Giron I believe the issue is that the popver doesn't have a unique ID
  • Or rather, it is the same popover on all the rows
  • gazinhio-1238177851878936667

    gazinhio

    1 year ago

    Yeah I think it's calling the same popover element for each one which is hooked up to the first status id
  • lucasg-1238177897555034194

    Lucas G

    1 year ago

    One sec lol
  • gazinhio-1238178103033860168

    gazinhio

    1 year ago

    I think you might have to set a random-number based id and assign it to the id attribute of each one.
  • lucasg-1238179263010832457

    Lucas G

    1 year ago

    But yeah, I cloned it and added an id and the numbers update
  • 1238179320153899100-image.png
  • 1238179417226739853-image.png
  • gazinhio-1238180436228964423

    gazinhio

    1 year ago

    Yeah, Lucas has got it, I've got it working in terms of showing the right popover element target with the right status id, but now it's showing in the wrong place 😆 🤷‍♂️ @Lucas G is it showing in the right place for you eg anchored to the main button?
  • lucasg-1238180637953888326

    Lucas G

    1 year ago

    Yes
  • Both the popover and the function need the same ID
  • gazinhio-1238180990669557911

    gazinhio

    1 year ago

    Ah yeah, the function
  • lucasg-1238181070852329533

    Lucas G

    1 year ago

    Speaking of which, I think I had a popover dropdown working without JS
  • Let me see if I can find it
  • Though I'd prefer to use the upcoming anchor updates
  • It worked though, let me see if I can find it
    🔥1
  • gazinhio-1238181336661889074

    gazinhio

    1 year ago

    🤯 Spill!
  • Please 😉
  • victoruxui-1238182043217559693

    Victor Giron

    1 year ago

    This is awesome! So I just need to add a variable with a random id and add it to the popover and the click event?
  • gazinhio-1238182551982706809

    gazinhio

    1 year ago

    You could just have the "orderstatus" and add the itemid attribute, if you know that'll be unique. But prob a randon number is safer. Yeah, add it as the id attribute for the drop-down <div>, the popover target and the param for the coded action for positioning.
  • victoruxui-1238183051603738847

    Victor Giron

    1 year ago

    It's working! Thanks so much guys! That was blocking me.
    I just need to find the way to hide the popover when user clicks on the button while the popover is visible haha
  • I think I have an idea for that
  • victoruxui-1238183382932783185

    Victor Giron

    1 year ago

    also is it a better idea to have the apicall for the status list inside the component or in the page?
  • Tod-1238183403493392426

    Tod

    1 year ago

    Great energy @Victor Giron! Your continuous contribution to the toddle Community just made you advance to Community Level 13!
  • gazinhio-1238183450129731695

    gazinhio

    1 year ago

    Thanks for the anchor code, gonna have to chance my drop-downs now I reckon. Although Lucas reckons he's got a way without the JS
  • gazinhio-1238183666086318192

    gazinhio

    1 year ago

    I'd deffo have it in the main page and pass it as a list, as it's calling it every time for every row at the moment.
  • gazinhio-1238183937088557120

    gazinhio

    1 year ago

    When they switch to a lower limit on API requests, the less calls the better.
  • lucasg-1238184018990600343

    Lucas G

    1 year ago

    I am not sure if it works on non-chromium browsers**
  • gazinhio-1238184030977921044

    gazinhio

    1 year ago

    If you've cracked this, you're a super-hero 😆
  • Just need to add it to the popover div and function
  • gazinhio-1238184873198489651

    gazinhio

    1 year ago

    Works on Arc and Safari so far
  • lucasg-1238185813490274395

    Lucas G

    1 year ago

    My version works on two main things
  • The popover API docs specify inset: unset to allow positioning
  • But the popover api also uses an overlay and goes on the window's top-layer
  • So I'm using overlay: none
  • Though overlay is not fully supported yet
  • So positioning would need to be tweaked for it to work everywhere untill the css properties are fully supported
  • lucasg-1238186640434921483

    Lucas G

    1 year ago

    I think there is another way to do it to make it more compatible but it requires adding a wrapper to it
  • gazinhio-1238186802142122035

    gazinhio

    1 year ago

    Nice. My CSS knowledge does that extend to even pretending to know what most of that means but I'm open to trying anything. 🤓 👍
  • lucasg-1238187191939760181

    Lucas G

    1 year ago

    lol I can try to wrap it to make it work better across browsers
    👍1
    💪1
  • gazinhio-1238188043517693972

    gazinhio

    1 year ago

    @Victor Giron If it's of any interest, here's the clone that I did as well. I changed loads of other stuff first before I came to the right conclusion 😳 but it all works, didn't break it! https://editor.nordcraft.com/projects/logistics_clone_alksdfjklasejflkasjd/branches/start/components/dropdown-status?canvas-width=800&canvas-height=800
    🔥1
  • gazinhio-1238188637217361951

    gazinhio

    1 year ago

    Sorry, I think I've just reposted Lucas' link! 😆
  • There you go!
  • victoruxui-1238189155922481233

    Victor Giron

    1 year ago

    hahah got it! thank you @
    👍1
  • Updated so it works on well on Safari too
  • lucasg-1238204314233602059

    Lucas G

    1 year ago

    I think I'll update my dropdowns with this going forward
  • Once some css properties are fully supported then it'll be even simpler
  • victoruxui-1238212453729308725

    Victor Giron

    1 year ago

    Question Lucas, does this relocate the popover to prevent to get out of the viewport when the target is close to the viewport boundaries?
  • lucasg-1238212835146731603

    Lucas G

    1 year ago

    I didn’t go that far
  • I only wanted to make a dropdown with the popover api
  • Since I’m using fixed values on it, it shouldn’t
  • victoruxui-1238283013138153553

    Victor Giron

    1 year ago

    Got it, the js action I used makes that happen, changes the position to keep the popover inside
  • gazinhio-1238539851088007269

    gazinhio

    1 year ago

    @Victor Giron @Lucas G Fellaz, big thanks for our convo re popovers yesterday. Just converted my main dropdown component to popovers using a lot of what we discussed, big thanks to the code shared by Victor. Took a bit more faffing around to get it to toggle on demand and a few code snippets but it's working great. V happy with it! 😊 If there's anything you'd like to me share about it just let me know. Have a good one guys!
  • stockton_f-1238540119993221271

    Stockton

    1 year ago

    Are you gonna make a package of the popover? 👀
  • victoruxui-1238540191053119551

    Victor Giron

    1 year ago

    Awesome!! Who would think popovers were so complex right? I’m happy with mine also, thanks a lot for the huge help
  • lucasg-1238544711556399208

    Lucas G

    1 year ago

    I just realized I never actually shared the dropdown popover component 😅
  • Pure CSS popover dropdown
  • gazinhio-1238598515660161024

    gazinhio

    1 year ago

    Probably should actually, a bit app-specific at the mo, maybe make it a bit more generic and then do it.