midzer / tobii

An accessible, open-source lightbox with no dependencies
https://midzer.github.io/tobii/demo/
MIT License
196 stars 20 forks source link

When using group, duplicate links always opens the first item in the group #114

Open roborourke opened 1 year ago

roborourke commented 1 year ago

Hi, we've encountered an issue whereby a series of links to open the lightbox in the same group will always open the ligthbox on the first item in the group rather than on the item for the link that was clicked.

For a solution would you rather:

  1. Always open on the clicked item
  2. A config option for whether to open on first item or selected item
roborourke commented 1 year ago

This might actually be an issue with the duplicate handling code. Possible if init is called twice, then the event listener from the add() method will already be there and then the event listener from the duplicate check will get added too and fire second.

The duplicate handling added in #59 doesn't try to figure out or pass an index to the open() function, not sure if it should try to find the index for what it's duplicating?

midzer commented 1 year ago

hi @roborourke and thanks for opening up!

I think a small demo of the issue would be good as I am not using tobii groups feature anywhere.