Code-component editor: NULL value error when reordering multivalue prop with empty slots in limited mode
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3583230. -->
Reported by: [kunal.sachdev](https://www.drupal.org/user/3685163)
Related to !870
>>>
<h3 id="overview">Overview</h3>
<p>When using a multivalue prop in limited mode with some empty values, reordering the values causes a NULL value error when attempting to save the component to the library. This issue only occurs after loading a previously saved component and reordering its values - the initial save works correctly.</p>
<h3 id="proposed-resolution">Steps to reproduce</h3>
<ol>
<li>Create a new component in the Code Editor</li>
<li>Add a Text prop with:
<ul>
<li>Enable "Allow multiple values"</li>
<li>Set value mode to "Limited"</li>
<li>Set limit count to 5</li>
</ul>
</li>
<li>Enter 3 example values in the first three slots:
<ul>
<li>"value1"</li>
<li>"value2"</li>
<li> "value3"</li>
<li>(leave slots 4 and 5 empty)</li>
</ul>
</li>
<li> Reorder the example values</li>
<li>Click "Add to component" → ✅ Saves successfully</li>
<li>Remove the component from the component library</li>
<li>Reorder the example values again </li>
<li>Click "Add to component" again → ❌ Null value error</li>
</ol>
<p><strong>Why this happens:</strong></p>
<ul>
<li>When loaded from backend, array has only filled values: ["value1", "value2", "value3"]</li>
<li>Component renders 5 slots but array has only 3 items</li>
<li>Accessing empty slots returns undefined</li>
<li>JavaScript converts undefined → null during JSON serialization</li>
<li>Backend rejects null values for string fields</li>
</ul>
issue