Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drag down issue on IE8, IE9 #160

Closed
deeta opened this issue Sep 27, 2012 · 5 comments
Closed

Drag down issue on IE8, IE9 #160

deeta opened this issue Sep 27, 2012 · 5 comments

Comments

@deeta
Copy link

deeta commented Sep 27, 2012

When dragging cells in IE, other text in the table gets selected - similar to a mouse drag on a normal web page.
If you select the cell on the first row/column and drag down slowly, you can see the issue.

I have an example here
http://jsfiddle.net/hU6Kz/548/

I tried adding the onselectstart="return false;" on the grid and it helps with the drag down problem but the copy/paste with Ctrl-C and Ctrl-V dont work.

I haven't looked deep enough, but I think if the onselectstart can be disabled during the drag events, the issue can be fixed.

You may have a better solution. Please let me know. Thanks!

@warpech
Copy link
Member

warpech commented Sep 27, 2012

I have also noticed it but didn't have good luck fixing it. Did you manage to fix it as you described?

@deeta
Copy link
Author

deeta commented Sep 28, 2012

didn't quite get to it, but I will keep you posted

@deeta
Copy link
Author

deeta commented Sep 28, 2012

I think I got it to work. Can you review this?

When the drag starts, add the "onselectstart" attribute

/**
 * Create DOM element for drag-down handle
 * @constructor
 * @param {jQuery} $container jQuery DOM element of handsontable container
 */
function FillHandle($container) {
  this.$container = $container;
  var container = this.$container[0];

  this.handle = document.createElement("div");
  this.handle.className = "htFillHandle";
  this.disappear();
  container.appendChild(this.handle);

  var that = this;
  $(this.handle).mousedown(function () {
    that.isDragged = 1; 
    /** START: IE Hack to disable text selection during the drag **/
    $(container).attr("onselectstart", "event.returnValue=false;");        
  });
}

When drag ends, remove it

  function onMouseUp() {
    if (priv.isMouseDown) {
      setTimeout(editproxy.focus, 1);
    }
    priv.isMouseDown = false;
    if (priv.fillHandle && priv.fillHandle.isDragged) {
      if (priv.fillHandle.isDragged > 1) {
        autofill.apply();
      }
      priv.fillHandle.isDragged = 0;
        /** END: IE Hack to disable text selection during the drag **/
      $(self.container).removeAttr("onselectstart");
    }
  }

@warpech
Copy link
Member

warpech commented Oct 17, 2012

Thanks @deeta, I think your solution really solves the problem! I just merged it with core, though I think I did it in less hackish way. Just added this few lines in FillHandle constructor:

this.$container.find('table').on('selectstart', function (event) {
  //https://github.com/warpech/jquery-handsontable/issues/160
  //selectstart is IE only event. Prevent text from being selected when performing drag down in IE8
  event.preventDefault();
});

Could you please recheck?

@warpech warpech closed this as completed Oct 17, 2012
@deeta
Copy link
Author

deeta commented Oct 18, 2012

That did the trick!
And yes, definetly much cleaner. Thanks again!

budnix pushed a commit that referenced this issue Nov 27, 2018
### Context
Updated description & added badge.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants