Empty (optional) date prop throws error upon reload, due to bug in client-side transform
>>> [!note] Migrated issue <!-- Drupal.org comment --> <!-- Migrated from issue #3550882. --> Reported by: [mohit_aghera](https://www.drupal.org/user/639098) Related to !202 >>> <h3 id="overview">Overview</h3> <p>When a date field in the SDC component is left empty, the component throws errors upon page reload after we save the content. </p> <p>This issue seems to occur because the empty date value is not properly handled in `dateTime` transformer.<br> When we save SDC component with empty date, <code>getPropsValues()</code> in <code>formutils.js</code> doesn't have date props.</p> <p>So, essentially it tries to call the <code>dateTransformer</code> with undefined <code>propSource</code></p> <p>Error:</p> <pre>Uncaught TypeError: Cannot read properties of undefined (reading 'sourceTypeSettings')<br>&nbsp;&nbsp;&nbsp; at Object.dateTime (transforms.ts:197:27)<br>&nbsp;&nbsp;&nbsp; at formUtil.ts:405:64</pre><h3 id="summary-steps-reproduce">Steps to reproduce</h3> <ul> <li>Add the date field in the card SDC component similar to the one in opened PR.</li> <li>Notice that date field doesn't have any example values, hence it will remain empty when we save.</li> <li>Add the SDC on canvas page.</li> <li>Save the page.</li> <li>Load the page again and we can notice the error.</li> </ul> <h3 id="proposed-resolution">Proposed resolution</h3> <p>For now, I think we can add the check to see if propSource is not undefined.<br> Add in MR</p> <h3 id="ui-changes">User interface changes</h3> <p>N/A</p>
issue