Tree drag and drop mode change not always sent to client?

I have both a Tree and Table in a Form. If the Form is in read-only mode, I turn off dragging. When in edit mode, I turn it on using code like the following in the form’s setReadOnly() overridden method:

	tree.setDragMode( readOnly ? TreeDragMode.NONE : TreeDragMode.NODE);
	table.setDragMode( readOnly ? TableDragMode.NONE : TableDragMode.ROW);

Whenever a new item is set into the form’s datasource, this sets the drag mode as expected. But when the user clicks the cancel buttons to that basically just change the readonly mode of the form, and then clicks the edit button to put it back in non-readonly mode, dragging is not enabled again. That is, the drag mode is never turned back on even if readOnly==false occurs when I am debugging it (so I am setting the drag mode correctly).

But then I found if I also set the read only for the table and tree, it worked as expected:

	tree.setReadOnly(readOnly);
	tree.setDragMode( readOnly ? TreeDragMode.NONE : TreeDragMode.NODE);
	table.setReadOnly(readOnly);
	table.setDragMode( readOnly ? TableDragMode.NONE : TableDragMode.ROW);

So, for me, this is fine and works, no issue, but is there some issue with setDragMode() that if you change it, it’s not sent to the client? I mean, I know the client receives a bunch of other stuff in my case because buttons appear/disappear, fields go from edit to display mode, etc., but the DND on those components stopped working (actually, I only know that it stopped on the Tree only at this point) once turned to readOnly and then back without also setting the component’s readonly status.

Thanks!

Has anybody considered this? Is this a bug? Maybe there’s already a ticket… It seems like a bug, that a change to the drag and drop mode should be transmitted to the client regardless of other UI changes.

Yes, it looks like there’s a bug. When I have a Tree and a Table and do this:

final CheckBox enabled = new CheckBox("Enabled", true);
enabled.addListener(new Property.ValueChangeListener() {
    
    public void valueChange(ValueChangeEvent event) {
        if (enabled.booleanValue()) {
            tree.setDragMode(TreeDragMode.NODE);
            table.setDragMode(TableDragMode.ROW);
            getWindow().showNotification("DD Enabled");
        } else {
            tree.setDragMode(TreeDragMode.NONE);
            table.setDragMode(TableDragMode.NONE);
            getWindow().showNotification("DD Disabled");
        }
    }
});
enabled.setImmediate(true);
layout.addComponent(enabled);

Strangely, after disabling DD, it is possible to drag from the Tree once and just once. After enabling it again, it’s not possible to drag from the Tree
before
dragging something from the Table.

Create ticket
#6320
.