rcdexta / react-trello

Pluggable components to add a kanban board to your application
https://rcdexta.com/react-trello/
MIT License
2.19k stars 481 forks source link

Event 'ADD_CARD' does not work with index: 0 and any other value for index #471

Open bernardimatheus opened 3 years ago

bernardimatheus commented 3 years ago

When I saw the source code for AppendCardToLane, it clears expects a parameter called index. But, When I tried to pass this parameter with the event ADD_CARD, the recent created card keeps on the last index of lane.

I'm trying to pass the index parameter this way:

eventBus.publish({
      type: 'ADD_CARD',
      laneId: String(response.id_stage),
      card: {
        id: response.idcustomer,
        title: response.name,
        description: formatPhone(response.phonenumber || '-'),
        laneId: String(response.id_stage),
      },
      index: 0,
});

To Reproduce Steps to reproduce the behavior:

  1. Use event.publish with type ADD_CARD.
  2. Try to add a card with index: 0
  3. You'll see the card at last index of lane.

Expected behavior I expect that passing this parameter to function event.publish will put the card at the first element of lane, not the last.

KaiSpencer commented 2 years ago

Hi @bernardimatheus, Ive raised a PR to address this issue.

cc @rcdexta @dapi