Closed eric-burel closed 11 months ago
This PR https://github.com/Devographics/Monorepo/pull/279 alters the value rather than using "virtual" last items. The problem is that it may mess up the value we store and complicates empty inputs deletion.
Instead we should turn lastItem
into lastItems
or virtualItems
. This means:
It complicates the current code too much, a reducer should be involved to have a clearer state here, with operations to make a virtual input real, manage the number or virtual inputs etc.
Done, the hook that handle virtual/real items is reusable and could serve controlled or uncontrolled components (it could be used in the CheckboxGroup namely). It would benefit from being rewritten with "useReducer" (should have started there...) but works well.
All in the title:![image](https://github.com/Devographics/Monorepo/assets/7983005/b1d220b1-4221-4694-867b-e57f4080f010)
The tricky part is not really to start with 2 fields, but to handle those fields afterwards.