alump / GridStack

Vaadin layout add-on using gridstack.js library
Apache License 2.0
10 stars 7 forks source link

DragHandle option is forgotten on page refresh #22

Open Midiman1 opened 7 years ago

Midiman1 commented 7 years ago

Hi, Thank you for making this very nice add-on!

I've noticed a behaviour that if a component is added with useDragHandle false, it works as expected -- until the page is refreshed/cache cleared. The component then reverts to dragHandle true (with the popup top-left move icon).

It would be good if the draghandle child option would remember its state after page refresh.

If you can point me in the direction of where in the code/client code such a fix could be made, I'm happy to fix it and submit.

Many thanks, Peter

alump commented 7 years ago

I'm trying to repeat this issue, but haven't found way to do it yet. There should not be any changes to drag handle when refreshing.

alump commented 7 years ago

Do you use @PreserveOnRefresh on your UI? If not then there is high change that you just end up reconstructing the GridStackLayout, and you do not set the useDragHandles correctly back on?

Midiman1 commented 7 years ago

Hi, Yes, I use @PreserveOnRefresh in my UI. I do my component init in onGridStackReady(), and use your neat trick of a boolean as a one-shot. So onGridStackReady() is called on each refresh, but the component creation is only called the first time. I've got 'round the issue by changing the dragHandle flag, but this was because I added some links to the control (these are externally created, so I can't use a GridStackButton here). So, I've got it all working, but maybe in the changes I've indirectly fixed something that was changing the dragHandle (I thought it was immutable?).

Many thanks for your help for making this excellent add-on!

Peter

alump commented 7 years ago

Are you using the Vaadin 8 -version (0.4.0+) or older version written for Vaadin 7? I only tested the 0.4 series yesterday.

And what are parent components of GridStackLayout on your application, all the way to UI class.

Midiman1 commented 7 years ago

I'm using 7.6.1. There's a number of parent components - our own internal ones - which generally inherit from VerticalLayout. The caveat to that is that the gridstack is wrapped [directly] with a DragAndDropWrapper (for file drop support). This is added to VerticalLayout (with some other comps) which is itself wrapped in a Panel for scrolling.

Since I've changed the way I use onGridStackReady(), I can't reproduce the issue.

Oddly, I do get some JS redraw issues as a result (grid doesn't repaint until forced by client-side e.g. a tab change and back again). This might be the underlying gridstack.js and not the add-on. To give an example, I have a 'sort' button which rearranges the items in the grid according to a 'titlebar' name. If I sort once, it's fine. If I move things around then sort again, there are no errors but the sort appears to have done nothing. A client-side repaint (e.g. cover the grid with another tab then bring the grid tab back) shows the sort did in fact work, just the component hadn't repainted. (I use Refresher rather than Push, as I've had so many push issues with V7) It could be the DragAndDropWrapper might be masking a paint, but would need to delve a bit deeper into it.

Many thanks for your help and expertise, Peter