ShuttleContainer receiving incorrect data-name
attribute based on number of re-renders
#139
Labels
bug
Something isn't working
Hi:
Thanks for this amazing library :).
I am building a shuttle that has filters on both source and target containers.
I am noticing that when the visibility of the Shuttle is toggled (for ex: Shuttle in a multi-step wizard, going back and forth between steps), the
data-name
attributes are swapped based on how many times the shuttle container is re-rendered (ex: number of characters entered in a container's filter input.)I have forked the codesandbox for the filter example and updated the implementation to more closely match our use-case.
CSB Link reproducing the issue
Steps to reproduce
data-name
attribute of the left shuttle container is nowtarget
instead ofsource
.Following relevant lines in the implementation are causing this behavior:
react-accessible-shuttle/src/components/Shuttle/ShuttleContainer.tsx
Lines 42 to 44 in 3bf2f8c
Upon entering every character in the container's filter Input, the ShuttleContainer is re-rendered causing the
id_int
to increment. Therefore, if you enter 2 characters in the filter input, then everything works as expected.Possible Solution
containerCount
ref
in the Context initialized to 0 ,instead of having a globalid_int
variable.containerCount
ref.Any thoughts or suggestions?
I'll be more than happy to send a PR if this approach makes sense?
The text was updated successfully, but these errors were encountered: