Skip to content
This repository has been archived by the owner on Jan 5, 2023. It is now read-only.

Possible Positioning error #124

Closed
peterjslater opened this issue Apr 30, 2020 · 7 comments
Closed

Possible Positioning error #124

peterjslater opened this issue Apr 30, 2020 · 7 comments

Comments

@peterjslater
Copy link

peterjslater commented Apr 30, 2020

Hi

I found a strange case where the positions of the dash-items are not where they are meant to be from the layout config.
see example

https://codesandbox.io/s/vue-responsive-dash-fhkwx?file=/src/App.vue

The box 2 should be at the top at y=0 however it is positioned at y=6
in code it is
items: [
{ id: "1", x: 6, y: 3, width: 6, height: 3 },
{ id: "2", x: 9, y: 0, width: 3, height: 3 },
{ id: "3", x: 0, y: 0, width: 8, height: 3 },
]

in debug it is
{"id":"2","x":9,"y":6,"top":386,"left":573,"width":3,"widthPx":178,"height":3,"heightPx":178,"draggable":true,"resizable":true},

There seems to be enough space at the top for it to fit.

I also found if i changed the order it seemed to fix it, e.g. following seems to work.

      items: [
        { id: "3", x: 0, y: 0, width: 8, height: 3 },
        { id: "1", x: 6, y: 3, width: 6, height: 3 },
        { id: "2", x: 9, y: 0, width: 3, height: 3 },
      ]

In my case the order is user defined so I can't control the order of the items, so this is an issue for me.

Hopefully you can find a fix.

Regards
Peter

@bensladden
Copy link
Owner

This is due to the items being compacted when added. If you turn compact off on dashlayout prop it appears as desired.

@bensladden
Copy link
Owner

Ill have a bit of a think how i can determine if an item has been added after being declared

@peterjslater
Copy link
Author

yes please, I would like to leave compact on if possible, so if user moves it around it fills the gaps, but then when the page positions are saved and the page refreshed it should return to the same position as it was when saved. Currently that is not the case.

@peterjslater
Copy link
Author

peterjslater commented Apr 30, 2020

Actually, I just tried your suggestion and it does solve the issue for me. I turn off compact unless they are in edit mode (draggable) to move the boxes around, and the boxes load in correct positions on a page refresh. So I think its all good for me.

@bensladden
Copy link
Owner

I think ive fixed it now. https://codesandbox.io/s/vue-responsive-dash-rj25l?file=/src/App.vue
It was worth fixing as if feel it will be a common problem

@peterjslater
Copy link
Author

Great thanks, will try it out next build.

@bensladden
Copy link
Owner

Closing for now. I can open again if there is are more questions

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants