Skip to content
This repository has been archived by the owner on Aug 1, 2024. It is now read-only.

Commit

Permalink
Automated g4 rollback of changelist 111352260.
Browse files Browse the repository at this point in the history
*** Reason for rollback ***

Breaks test

*** Original change description ***

Allow further propagation of `mousedown` event for draggable elements.

There is currently an issue when default mousedown event gets cancelled for
draggable elements.
Consider an example when you have a draggable div with some
input inside. If you click on input, it won't get focus and you won't be able
to type anything, because focus is a default event which gets eaten by
drag-and-drop.

I assume that cancelling of default mousedown has been done in order to
prevent text selection while draggi...

***
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=111522388
  • Loading branch information
concavelenz committed Jan 6, 2016
1 parent 2748102 commit 623d4c8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 31 deletions.
2 changes: 1 addition & 1 deletion closure/goog/deps.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions closure/goog/fx/abstractdragdrop.js
Original file line number Diff line number Diff line change
Expand Up @@ -1404,6 +1404,8 @@ goog.fx.DragDropItem.prototype.maybeStartDrag_ = function(event, element) {

this.startPosition_ = new goog.math.Coordinate(
event.clientX, event.clientY);

event.preventDefault();
};


Expand All @@ -1430,9 +1432,6 @@ goog.fx.DragDropItem.prototype.mouseMove_ = function(event) {
this.eventHandler_.removeAll();
this.parent_.startDrag(event, this);
}

// Prevent text selection while dragging an element.
event.preventDefault();
};


Expand Down
31 changes: 4 additions & 27 deletions closure/goog/fx/abstractdragdrop_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ goog.require('goog.math.Box');
goog.require('goog.math.Coordinate');
goog.require('goog.style');
goog.require('goog.testing.events');
goog.require('goog.testing.events.Event');
goog.require('goog.testing.jsunit');

var targets = [
Expand Down Expand Up @@ -508,22 +507,6 @@ function testScrollableContainersCalculation() {
assertEquals(container, group.targetList_[1].scrollableContainer_);
}

function testMouseDownEventDefaultAction() {
var group = new goog.fx.AbstractDragDrop();
var target = new goog.fx.AbstractDragDrop();
group.addTarget(target);
var item1 = new goog.fx.DragDropItem(document.getElementById('child1'));
group.items_.push(item1);
item1.setParent(group);
group.init();

var mousedownDefaultPrevented =
!goog.testing.events.fireMouseDownEvent(item1.element);

assertFalse('Default action of mousedown event should not be cancelled.',
mousedownDefaultPrevented);
}

// See http://b/7494613.
function testMouseUpOutsideElement() {
var group = new goog.fx.AbstractDragDrop();
Expand Down Expand Up @@ -600,20 +583,14 @@ function testMouseMove_mouseOutBeforeThreshold() {
draggedItem = item;
};

var event = new goog.testing.events.Event(goog.events.EventType.MOUSEOUT,
childEl);
// Drag distance is only 2.
event.clientX = 8;
event.clientY = 10;
var event = {'clientX': 8, 'clientY': 10, // Drag distance is only 2
'type': goog.events.EventType.MOUSEOUT, 'target': childEl};
item.mouseMove_(event);
assertEquals('DragStart should not be fired for mouseout on child element.',
null, draggedItem);

var event = new goog.testing.events.Event(goog.events.EventType.MOUSEOUT,
itemEl);
// Drag distance is only 2.
event.clientX = 8;
event.clientY = 10;
var event = {'clientX': 8, 'clientY': 10, // Drag distance is only 2
'type': goog.events.EventType.MOUSEOUT, 'target': itemEl};
item.mouseMove_(event);
assertEquals('DragStart should be fired for mouseout on main element.',
item, draggedItem);
Expand Down

0 comments on commit 623d4c8

Please # to comment.