Move Items Between Two Lists

Write the code, see it run, pass the checks.

The problem

  • hard
  • Code
  • Pro

The Team component gets a people prop, a list of names (the preview uses Ada, Ben, Cleo, Dev and Eve). Show two lists with the accessible names "Available" and "Chosen" (for example aria-label, or aria-labelledby pointing at a heading); everyone starts in Available, and both lists always show, even when empty. Each person is a list item holding a checkbox labelled with just their name. An "Add selected" button moves the ticked people in Available to Chosen, and a "Remove selected" button moves the ticked people in Chosen back. People who move are unticked; anyone ticked who didn't move stays ticked. Both lists keep the people in the prop's order, whatever order they moved in. Each button is disabled while nobody in the list it moves from is ticked. Below, show a line like "2 of 5 chosen".

Your code must pass

  • Everyone starts in Available, with both buttons disabled
  • Add selected moves the ticked people to Chosen
  • Both lists keep the prop's order
  • Each button only moves ticks from its own list