Question presented to candidate: "Our report builder lets users pick which columns appear in an export. Build a transfer list: available columns on the left, chosen columns on the right, checkboxes to mark items, and buttons to move the checked ones across, or everything at once."
Requirements:
- Two panels, "Available" and "Chosen", each with a list of checkboxes, a filter box and a header checkbox that checks every item currently shown.
- The header checkbox is checked when all shown items are checked, unchecked when none are, and indeterminate when only some are.
- Four buttons: move all shown right, move checked right, move checked left, move all shown left; each is disabled when it would do nothing.
- Items keep the original (master) order on both sides, whatever order they were moved in; moved items arrive unchecked.
- The component is controlled: the parent receives the ids on the right as an array, in master order.
What a strong answer should cover:
- A single source of truth: one master list plus the set of chosen ids, with both panels derived from it instead of two arrays that are spliced back and forth.
- A
Setof checked ids, filtering that applies only to what is shown, and moves that act on the shown and checked items. - The
indeterminatestate is a DOM property with no HTML attribute, so it must be set through a ref (React) or a property binding (Vue / Angular). - Disabled logic derived from the same data, and accessible labels for the icon buttons and checkboxes.
- Splitting a stateful container from a presentational panel used twice.
Clarifying questions expected:
- "Should the chosen side keep the master order or the order items were moved in?"
- "Do 'move all' buttons act on everything or only on the filtered items?"
- "Should the chosen list be reorderable?"
Code / implementation expected: Yes. A controlled transfer-list component built from a reusable panel component.