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

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

Open bernardimatheus opened this issue 3 years ago • 1 comments

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.

bernardimatheus avatar Sep 13 '21 11:09 bernardimatheus

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

cc @rcdexta @dapi

KaiSpencer avatar Oct 06 '21 10:10 KaiSpencer