react-trello icon indicating copy to clipboard operation
react-trello copied to clipboard

[Firefox specific] onClick handler on cards is triggered when drag&drop --

Open sylvain-hamel opened this issue 5 years ago • 7 comments

Describe the bug When you drag and drop a card, the card's onClick handler should not be called but on Firefox it is.

To Reproduce Steps to reproduce the behavior:

  1. Create a board
  2. Use a custom card template
  3. In you card template, handle onClick ( const Card = <div onClick={()=>console.log('click')}/>)
  4. Add a card to your board
  5. On Chrome or Edge: drag the card to another column. The onClick handler IS NOT called and this is correct.
  6. Try the same on Firefox (drag the card to another column). The onClick IS CALLED. But this is not a click, this is a drag&drop gesture.

Expected behavior The onClick handler should not be called

Desktop (please complete the following information):

  • OS: Windows 10
  • Browser Firefox
  • Version 65

sylvain-hamel avatar Mar 13 '19 03:03 sylvain-hamel

Its happening with me too using version 2.0.9 On Safari is working normally

  • OS: MacOS Mojave 10.14.3
  • Browser Firefox
  • Version 66.0.1

pedropazello avatar Mar 27 '19 00:03 pedropazello

This also happen in inet11.

  • OS: Windows 10
  • Browser Internet Explorer
  • Version 11

josepichu avatar Sep 26 '19 07:09 josepichu

Hey! Any updates about the issue? Or it is are not going to be resolved?

rhryhorenko avatar Dec 03 '20 13:12 rhryhorenko

I've solved the issue in the Firefox browser by adding draggable={cardDraggable} to the header inside custom card. Where cardDraggable is a prop. Also you will need to add onDragStart={e => e.preventDefault()} to header. This is needed to avoid this issue - https://github.com/rcdexta/react-trello/issues/348

rhryhorenko avatar Dec 04 '20 09:12 rhryhorenko

I am also facing this issue in Mozilla firefox on-card drag and not just by dragging the card header. But this is replicable even on card drag not just on the header. Need one suggestion on how to pass draggable={cardDraggable}, I am using a separate custom Component to render the card, something like this

let customCard = (data, cardDraggable) => {
      return ( <CustomCard data={data}></CustomCard>)}

and then accessing the cardDraggable inside CustomCard Component something like

<header draggable={this.props.cardDraggable} onDragStart={e => e.preventDefault()}></header> I feel I am not doing it right. Can anyone help to correct this?

garimahans15 avatar Feb 18 '22 13:02 garimahans15

Hi @Proxi01 , Can you please help me on this?

garimahans15 avatar Feb 21 '22 15:02 garimahans15

Hi, My issue got resolved by just adding onDragStart={e => e.preventDefault()} to the parent tag of custom card. Thanks for the help

Regards!!! Garima

garimahans15 avatar Mar 10 '22 09:03 garimahans15