Skip to main content

Hi, i come from my another question where i added items to existing group. But i encountered not expected behaviour when fetching selected group. What i do:

  • Select group of items and run my code (see bellow):

     

  • Delete one item from this group via UI
  • Select this group again. I can see, that counter of the items updated in UI
  • Then i run my code wich triggers onClick()(thanks to @Mettin ):  
    export async function checkGroupItems() {
    let selectedElements = await miro.board.getSelection();
    if (selectedElements) {
    let group = await miro.board.getById(selectedElementse0].groupId);
    console.log(group);
    }
    }

     

  • And i still get that deleted item in group.items

     

Is this a bug or is it my code caches group in somewhere? I call my function from app.jsx

<div className="cs1 ce12">
<a
onClick={(event) => checkGroupItems()}
className="button button-primary"
>
Check group items
</a>
</div>

I come from Java so i may not quite understand caching in js or how script file itself stored in memory. 

I asked my colleague that worked on the grouping SDK methods to take a look. One small thing: Your `<a/>` tag should be a `<button/>` tag since you are not linking anywhere but executing an action


Thanks, that works too. Im doing ui thing for a 3rd day and i have no idea what’s going on there apart from some info from tutorials and just want to execute some code with buttons.


Well cool to hear you started with Miro right away!

Lesson of the day:
Go to another page? <a/>
Execute an action? <button/>


Hey @jirimoarichi ,

 

We've just released the fix for the issue. You can now try again your code snippet and the group items should updated correctly once an item gets deleted, either from the UI or using the WebSDK.

Just don't forget to fetch the group again after the item is deleted, as the object can be cached on your side of the app and you need to work with the object at its latest state from the board.


Reply