Bug: Serialization failing
Hi there,
I have a particular circumstance where the serialization is not consistent with what I am seeing on the screen.
I have built a plunker to demonstrate this. This plunker is based on the original serialization demo. The plunker may be found here.
The plunker shows 5 blocks displayed in a single gridstack. At start up, it uses makeWidget to create the blocks. I have added an id to each block, so it can be tracked.
When you change the location of a block, a change event fires, and I output the serialized content into the text box. So you will be able to see what the location is of each block after dragging and dropping, much like when you click on the Save button. Mind you, if you click on Save, it makes no difference; the block is still in the wrong location in the json.
Run the plunker, maximize your screen, and stretch the running panel until you can see at least three tiles (I say this, because I've seen a scenario where the tiles aren't painted properly and only show up top to bottom. I don't know if that's a problem - it could be a plunker only issue and is not something I need to solve now.)
Take tile 2 and drag it to position x=1, y=0. It should now be the only tile located on the top row, and the full width tile should now appear pushed down onto the second row.
Next pick up tile 2 and drag it to position x=0, y=0. Once you place this, tile 5 appear next to tile 2. It has taken tile 5 from the bottom of the gridstack, and placed it automatically in position x=6,y=0.
Take a look at the output in the text box. It shows:
[
{
"id": "tile1",
"x": 0,
"y": 7,
"w": 12,
"h": 5
},
{
"id": "tile2",
"x": 0,
"y": 0,
"w": 6,
"h": 7
},
{
"id": "tile3",
"x": 0,
"y": 12,
"w": 6,
"h": 7
},
{
"id": "tile4",
"x": 6,
"y": 12,
"w": 6,
"h": 7
},
{
"id": "tile5",
"x": 6,
"y": 19,
"w": 6,
"h": 7
}
]
Note that it thinks tile 5 is still located at position x=6, y=19, which is now wrong as it should be x=6, y=0.
To demonstrate that this is not some sort of delay issue, if you now click on the Save button, it will still output the same wrong data.
This is the craziest thing. What on earth is making 5 move up?
Holy smokes. I think you just exemplified https://github.com/troolee/gridstack.js/pull/672 , which I had just asked for an example of. I'm not positive, but I can say for sure that it's erasing the y-values for the CSS, so the widget appears moved but it isn't actually moved dun dun dunnn. I'll try to see if the PR fixes the issue when I have a chance.
@tonywr71 Can you try using the src dev branch and see if this works any better? Via https://github.com/troolee/gridstack.js/pull/672 I've tested against my own project and it does fix the weird reordering. I don't know if it'll fix your actual serialization problem but maybe it was just caused by this other issue.
That version is all good! See new plunker here.
I didn't realise that I could already access your new version. I'll have to create a scripts folder and import it from there instead of npm.
Awesome! - Actually, you can still access it from npm.
https://stackoverflow.com/questions/39732397/install-specific-branch-from-github-using-npm
Just remember to stop using the develop branch when the new one is out. So glad that this fixes your issue!
Awesome! - Actually, you can still access it from npm. https://stackoverflow.com/questions/39732397/install-specific-branch-from-github-using-npm
but npm install git://github.com/github.com/troolee/gridstack.js#1.0.0-dev --save won't be always getting the latest code since the rev isn't increasing and I assume it gets cached locally, no ?
I can confirm that using the dev branch causes issues with npm. The sooner this product is released and versioning started, the better. Thanks for this awesome product!