Closed plasticmacaroni closed 1 year ago
When uncollapsing a section, it is not brought back to the original position, which is probably functionality that users would expect. However, this would require tracking a tile's position with some variable, and as I understand it, tile order could change as context updates. Not sure what the best approach would be.
Elements now get a data attribute that stores their original position, and are returned to that position in the overall list of tiles when uncollapsed. Still hunting for bugs with this implementation, but it was only 4 more lines of code.
If items are removed from the tileset, the insert index can go out of bounds.
Working on a commit to insert either at the original position, or if it is past the total number of tiles, insert at the last possible position.
Actually, I take that back. The insertBefore
function does not throw an error if you try to insert before an index that does not exist. Instead, if the index provided is out of bounds, it will default to appending the element at the end of the parent element. When the tile is collapsed again, it stores a new data attribute pointing to its new location, as well.
It appears insertBefore
works like this:
parentNode.insertBefore(newNode, referenceNode)
: This inserts newNode
into the parentNode
before referenceNode
.referenceNode
is null
, the newNode
is inserted at the end of the list of child nodes.referenceNode
is not a child of parentNode
, the function does nothing.I can't find a way to throw an error even with constantly changing/disappearing tiles. The worst that could happen is that a tile could return to a position it wouldn't naturally occur at, with a slight offset, which doesn't seem like an issue to me.
Testing this functionality -- attempt is to move tiles to the bottom of each section when collapsed.
I've also added the solid border to the top of all tiles for now, otherwise, there's inconsistency when they're moved below.