Inconsistency with setItemIndex and Navigator / World state
See original GitHub issueWhen calling setItemIndex
inside a add-item
callback, there is an inconsistency in the World and Navigator states. The former has the item that triggered the add-item
callback, but World does not.
So, given this use case:
- add an item with viewer.addTiledImage
- code in
add-item
callback inspects world._items and determines that one of the items needs to be moved to top of the list, so it callssetItemIndex
setItemIndex
updates World state, and dispatches theitem-index-change
eventitem-index-change
fires.
However, since the Navigator state does not yet have the item from add-item
, an error is thrown:
Uncaught Error: Index bigger than number of layers.
I’m not sure if this matters in our use case, since the Navigator state eventually does include the item, it is just in a different ordering than World. However, I think the expected behavior would be that state for both would be updated when the add-item
callback fires.
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (8 by maintainers)
Top Results From Across the Web
Hyperledger Fabric world state inconsistency - Stack Overflow
I created a paper with the paperlist abstraction and then changed one of its attributes. When getting the state (getState) for a particular ......
Read more >Unreal Engine 5.1 Release Notes
The navigation data is now externally packaged, which means building a world-partitioned Navmesh does not dirty the main map anymore. In addition, when...
Read more >Alexa.Presentation.APL Interface Reference | Alexa Skills Kit
The Alexa.Presentation.APL interface provides directives and requests that display content on a device with a screen, such as an Echo Show.
Read more >browser-extension/changelog.txt at master - openseadragon
Fixed: setItemIndex method not working with navigator inside "open" event ... Fixed problems with zoom/pan constraints with certain extreme settings (#965).
Read more >Application Cache is a Douchebag - A List Apart
... to keep growing and growing until it hits some kind of browser cache limit and the world explodes. ... setItem( 'index', JSON.stringify(...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Good catch! I guess to fix it we would have to make sure the navigator gets the add item event before anyone else.
Meanwhile a workaround could be putting a setTimeout of 1 in your add-item handler, to give the chance for the navigator to catch up.
Thank you for reporting this! If you’re interested in working on a fix, I’m happy to answer any questions you have along the way. Otherwise hopefully someone will take an interest in it.
Fixed by #2005