Sortable icon indicating copy to clipboard operation
Sortable copied to clipboard

:hover bug

Open danielsedlacek opened this issue 10 years ago • 27 comments

Hi Konstantin

there is a small bug, if the list element has hover effect this is strangely copied to the nearby elements when dragging starts.

http://jsbin.com/lipatehubu/1/edit?css,js,output

Thanks for this amazing library!

danielsedlacek avatar Jan 20 '15 10:01 danielsedlacek

This native browser behavior. Try workaround: http://jsbin.com/pafisicika/1/edit?css,js,output

RubaXa avatar Jan 20 '15 10:01 RubaXa

amazing, thanks!

danielsedlacek avatar Jan 20 '15 10:01 danielsedlacek

I still see bugs here in Chrome 40.0.2214.94 (Mac 64-bit). The workaround doesn't help. And behavior is not stable. It looks like from time to time some blocks don't lose :hover state so I see more than one hovered items.

shvechikov avatar Feb 09 '15 12:02 shvechikov

I'm noticing the same thing as @shvechikov, the :hover state seems to be applied to a dragged element's adjacent nodes. As an unfortunate workaround, I'm using mousenter and mouseleave events to style hovered elements.

jfurrow avatar Mar 11 '15 18:03 jfurrow

Still no solution? Workaround didn't helped me too Chrome Version 49.0.2623.87 m

EDIT: Made my own workaround ( possible might work only for me ):

  1. Have added hidden helper block with position: absolute inside sortable elements over sensetive elements
  2. Display it onStart
  3. Hide it onEnd

igloro avatar Mar 21 '16 11:03 igloro

I have the same issue in Chrome. On drag end, the row after the dropped row receives :hover state unintentionally. It is only removed as soon as I actually hover it and then move the cursor off.

I'm using the Angular version and using jfurrow's workaround of mouseenter and mouseleave, which does work for me.

dannybranton avatar Mar 28 '16 16:03 dannybranton

I have same issue with @dannybranton

oknoorap avatar Apr 01 '16 04:04 oknoorap

Hi. I have the same issue using Chrome. I think this is related to https://bugs.chromium.org/p/chromium/issues/detail?id=410328

maxired avatar Apr 06 '16 12:04 maxired

My partial solution was: In mouseenter I add the hover class and mouseleave I remove the hover class.

marlonmleite avatar Jul 19 '16 18:07 marlonmleite

My solution:

.is-dragging {
  pointer-events: none;
}
onStart: function () {
  this.el.classList.add('is-dragging');
},
onEnd: function (evt) {
  this.el.classList.remove('is-dragging');
}

asakasinsky avatar Jan 31 '17 03:01 asakasinsky

Same issue on Chrome and Chromium 57. None of the workarounds seems to work.

My own workaround: Just don't use :hover

.list-item
  // Styles...
  &--hover
    background-color: your-color
window.onload = function(){
  var list = document.getElementById('list');
  Sortable.create(list);
  $('.list-item').bind('mouseenter', function(){
    $(this).addClass('list-item--hover');
  }).bind('mouseleave', function(){
    $(this).removeClass('list-item--hover');
  });
}

pedroadame avatar Apr 12 '17 07:04 pedroadame

Same issue on Chrome 60.

kuroky360 avatar Sep 29 '17 08:09 kuroky360

Same on Chrome 62

jstevensstein avatar Nov 22 '17 01:11 jstevensstein

Same on Chrome 66

itayganor avatar May 04 '18 16:05 itayganor

Same problem. Can this issue be reopened? @RubaXa

tomo-it avatar Aug 07 '18 03:08 tomo-it

Same on Chrome 76

quantpioneer avatar Aug 21 '19 19:08 quantpioneer

Same on Chrome 81

gambolputty avatar May 11 '20 11:05 gambolputty

Same on Chrome 85

garcia-marco avatar Sep 16 '20 15:09 garcia-marco

Reopening as it keeps happening.

waynevanson avatar Sep 18 '20 01:09 waynevanson

Workaround from @igloro works. You can use :before/:after pseudo element instead of real element: https://codesandbox.io/s/demo--sjs-disable-hovering-siblings-using-overlay-pel05

olegcherr avatar Oct 21 '20 06:10 olegcherr

Same on Chrome 96

asssc avatar Dec 27 '21 13:12 asssc

Same on Safari 15.1

AlexR2D2 avatar Jan 30 '22 07:01 AlexR2D2

My solution:

JSBin

var onDrag=false;

Sortable.create(foo, {
  group: 'foo',
  animation: 100,
  onStart:event=>onDrag=true,
  onEnd:event=>onDrag=false,
});

document.querySelectorAll("li").forEach((item) => {
  item.addEventListener("mouseenter", function () {
    if (!onDrag) {
      this.style.backgroundColor = "pink";
    }
  });
  item.addEventListener("mouseleave", function () {
    this.style.backgroundColor = "#eee";
  });
});

a90120411 avatar Feb 21 '22 11:02 a90120411

Same on Chrome 99

toniengelhardt avatar Mar 26 '22 13:03 toniengelhardt

Still the same on Chrome 111. Not an issue on FF.

steve-scorn avatar Apr 02 '23 12:04 steve-scorn

Can we please have a fix? Same on Chrome 122.0.6261.112. No issue on Firefox.

ianthedev avatar Mar 06 '24 12:03 ianthedev