jakezatecky / react-dual-listbox

A feature-rich dual listbox for React.
https://jakezatecky.github.io/react-dual-listbox/
MIT License
110 stars 58 forks source link

Pass Selected List on runtime dynamically and then display in Right hand side of selected list. ** Items dont move to Left hand side #182

Closed s30java closed 2 years ago

s30java commented 2 years ago

Describe the bug I have a list of options list which is populated from REST GET call ,which is working fine and displayed on left hand side and on click moving properly to RHSide but while adding selected elements i am facing difficultly in moving those items on left hand side(LHS), these LHS elements are again coming from another REST GET calls to be displayed as part of selected list.

Note: if i declare elements in constructor for LHS as shown below it works fine but when i try to push 'one' in selectedList array then issue comes of elements not moving to Left hand side. userid: 'Administrator', selectedList: ['one],

Reproduction steps 1) Add all elements for LHS using a get api this.leftside.map(feature => ( leftside.push( { value: feature.Code, label: feature.Description }) )) 2) Add all elements to be displayed on RHS for (const element of this.state.rightside) { selectedList.push(element.Code) } 3) now try to move elements from RHS to LHS , it will not work

Expected behavior Want to add values for selected list on runtime and not at constructor level to make this selected list work and move elements from LHS(selected) to RHS(options)