PDA

View Full Version : [CLOSED] Odd selection when dragging in ItemSelector and MultiSelect



mark.peters
20 Nov 2013, 1:40 PM
In DD-enabled widgets that use Ext.view.DragZone, dragging an item that wasn't already selected has odd behavior. Say I'm using an ItemSelector with items {A, B, C} on the left and {X, Y, Z} on the right. I single-click B to select it. Then, without holding CTRL or SHIFT, I drag C to the right pane. What happens is that B comes too.

My UX designer and I agree that this is unexpected UX, because I am not holding CTRL or SHIFT as if to retain the existing selection. As it is, drag and drop is always a two-click operation: one to clear the current selection, and a second to initiate the drag. When I start dragging an unselected item, I should only get that item, not other selected items. This is how I have always seen drag and drop behave, including Windows and Gnome file explorers. Compare that to when I start dragging one of the selected items: then I should get all selected items.

The only demo of ItemSelector I could find actually behaves how I would expect: http://dev.sencha.com/deploy/ext-4.0.0/examples/multiselect/multiselect-demo.html. However, the behavior and code has since changed.

https://fiddle.sencha.com/#fiddle/1r1

My current workaround is to override Ext.view.DragZone:


Ext.define('my.overridden.DragZone', {
override: 'Ext.view.DragZone',
onInitDrag: function(x, y) {
var me = this,
data = me.dragData,
view = data.view,
selectionModel = view.getSelectionModel(),
record = view.getRecord(data.item);


// Update the selection to match what would have been selected if the user had
// done a full click on the target node rather than starting a drag from it
if (!selectionModel.isSelected(record)) {
// CHANGE: adding the dragged record to the selection is really wonky
// compared to simply setting the dragged record as the new selection
// selectionModel.select(record, true);
selectionModel.select(record, false);
// END CHANGE
}
data.records = selectionModel.getSelection();


me.ddel.update(me.getDragText());
me.proxy.update(me.ddel.dom);
me.onStartDrag(x, y);
return true;
}
});



However, it's not ideal as it doesn't respect shift or control being held as Windows Explorer or most other drag-and-drop components do.

Gary Schlosberg
26 Nov 2013, 11:02 AM
Thanks for the report! I have opened a bug in our bug tracker.