react-sortable-hoc icon indicating copy to clipboard operation
react-sortable-hoc copied to clipboard

Drag and drop on firefox is glitchy.

Open arconus opened this issue 9 years ago • 16 comments

On firefox when I try to drag and drop items after dragging for a few pixels the cursor changes to crossed out circle and the drag stops. When I let go of the mouse button I am dragging the item again and clicking releases the drag and drops the item. here is a video: https://youtu.be/q1h9SO59GTU

On chrome everything works the way I would expect. here is a video: https://youtu.be/Aijcz_HJOyc

Here is my setup code.

const styles = theme => ({
  grid: {
    width: 208,
    marginLeft: 'auto',
    marginRight: 'auto',
    '@media (min-width: 500px)': {
      width: 'calc(100% + 16px)',
      margin: -8,
      paddingRight: 20,
      paddingLeft: 20,
    },
  },
  sortableHelper: {
    zIndex: 3000,
  },
  sortableItem: {
    margin: 8,
    width: 192,
    height: 256,
    display: 'inline-block',
  },
  sortableContainer: {
    margin: 0,
    marginTop: -8,
    padding: 0,
  }
});

const SortableItem = SortableElement(({value, classes}) =>
  <div className={classes.sortableItem}>
    <RouteTile route={value} disableClick showRouteLine/>
  </div>
);

const SortableList = SortableContainer(({items, classes}) => {
  return (
    <ul className={classes.sortableContainer}>
      { items.map((route, index) => (
        <SortableItem classes={classes} key={route.id + (route.climb_id ? '_' + route.climb_id : '')} index={index} value={route} />
      ))}
    </ul>
  );
});

class BoulderRouteGrid extends React.Component {
  render() {
    const classes = this.props.classes;
    return (<SortableList helperClass={classes.sortableHelper} axis={'xy'} items={this.props.routes} classes={classes} onSortEnd={({oldIndex, newIndex}) => {this.props.onRouteMoved(oldIndex, newIndex)}} />)
  }
}

export default withStyles(styles)(BoulderRouteGrid);

The one thing somewhat unique is that the scrollable container is inside a material UI Dialog.

arconus avatar Nov 24 '17 23:11 arconus

I'm also having some problems with Firefox, not exactly like yours, but every time I drag outside of the container it will draw me the item outside and stay there like a ghost or a placeholder. But I think this bugs only happen in the new Firefox, I'm using Firefox Nightly. I tried an old version of Firefox and Chrome and it's working fine.

Edit: The funny thing is that the demo works fine, but the example in the README.md (with the item having a border 1px solid black and a padding of 20px) doesn't.

carloswbarros avatar Nov 25 '17 16:11 carloswbarros

I can confirm that the same issue appears consistently in Firefox, but not Chrome, using both 0.6.7 and reverting to 0.6.6. Our items drag vertically rather than horizontally, but the behavior (moving a small amount in the drag direction, then stopping, and sometimes following the cursor afterwards until it releases on click) is the same described/demonstrated here.

Info for Firefox (glitching): http://whatismybrowser.com/w/8WT8EDR Info for Chrome (working): http://whatismybrowser.com/w/7RTXPGK

mc-funk avatar Dec 04 '17 19:12 mc-funk

Have the same issue in Firefox with an image as reordable item. Adding a pseudo-element on top of my sortable element did a trick for me, but it's not a really great solution ofc. But it works anyway.

lemurry avatar Dec 25 '17 12:12 lemurry

@lemurry can you clarify what you meant about adding a pseudo-element? A workaround for this issue would be very helpful. Thank you!

mc-funk avatar Dec 29 '17 23:12 mc-funk

I'm using handles in FF and I don't get any sortable behaviour, doesn't pick up/drag at all.

robhadfield avatar Jan 02 '18 09:01 robhadfield

@mc-funk had the same problem and this worked for me -> DraggedStuff is styled div:

  <DraggedStuff>
    <ImageWrapper src={src} alt={desc} />
  </DraggedStuff>
));

.DraggedStuff  {
.....style...
position: relative;
&:after {
position: absolute;
content: '';
top:0;
bottom: 0;
right:0;
left:0;
}
}

byPawel avatar Jan 02 '18 09:01 byPawel

Thanks @pavveu - I solved mine with CSS too. I was using an inline-block element as the handle but making this a block and adding the &:after element means I can now grab. Woot!

Cheers all.

robhadfield avatar Jan 02 '18 12:01 robhadfield

I figured out that it happens when the SortableItem has position: relative and it has a child with position: absolute and the dragging is started on that child.

So setting pointer-events: none on the child solves it for me.

zerazeru avatar Mar 09 '18 14:03 zerazeru

https://github.com/clauderic/react-sortable-hoc/issues/253

this issue also helps with this

dagadbm avatar Jun 05 '18 14:06 dagadbm

I figured out that it happens when the SortableItem has position: relative and it has a child with position: absolute and the dragging is started on that child.

So setting pointer-events: none on the child solves it for me.

Worked for me, but in my case the child elements has the pointer events and which cannot remove... Any alternative Solution ?

Girijashankar-CS avatar Feb 05 '19 12:02 Girijashankar-CS

Finesse's comment from #253 helped me. Preventing the event default onSortStart of the SortableList did the trick. He does mention that it won't work when

the pressDelay or the distance option is set.

But if you're not using these then you might be able to get away with it.

jamesalester avatar May 08 '19 10:05 jamesalester

Is there any other work around to get the drag n drop work smoothly in Firefox? I tried the &:after { } styles as suggested by @pavveu and also the pointer-events: none styles by @zerazeru , both didn't work for me. From @jamesalester 's comment above, preventing the event default onSortStart did work, but I can't use it as I'm using distance={1} as a work around to allow the click events work. Does anyone has any other solution to fix this issue in Firefox? Thanks

soorajkarikkan avatar Nov 25 '19 10:11 soorajkarikkan

&:after works for me

jacksontong avatar Jan 03 '20 10:01 jacksontong

Same here. Thanks for help

AkimSolovyov avatar Jan 28 '20 16:01 AkimSolovyov

@soorajkarikkan Enabling the pointer-events on hover works for me.

  > * {
    pointer-events: none;
  }
  &:hover .clickable {
    pointer-events: auto;
  }

albohlabs avatar Jul 02 '20 08:07 albohlabs

I encountered this issue as well. Setting my drag handle img to display: inline-block fixed it.

ghargrove avatar Sep 01 '20 03:09 ghargrove