Class values in menu link submit hook are appended instead of replaced
>>> [!note] Migrated issue <!-- Drupal.org comment --> <!-- Migrated from issue #3212105. --> Reported by: [enzipher](https://www.drupal.org/user/179782) >>> <h3 id="summary-problem-motivation">Problem/Motivation</h3> <p>When having a value in the "class" attribute field, and saving a menu item, the value gets appended to the class array. This eventually leads to a "Class cannot be longer than 128 characters but is currently [X] characters long." message. In addition, it's not possible to remove previously submitted values.</p> <h4 id="summary-steps-reproduce">Steps to reproduce</h4> <p>1. Add a value that is 65 or more characters long to the "class" field.<br> 2. Save the menu item.<br> 3. Save the menu item again without making any changes.<br> 4. Validation error is displayed, and it's not longer possible to save.</p> <h3 id="summary-proposed-resolution">Proposed resolution</h3> <p>Attached patch replace instead of append values to the class array.<br> Note that it may be that current logic is due to an edge case I'm not currently aware about.</p> <h3 id="summary-remaining-tasks">Remaining tasks</h3> <p>There might be a need for an update hook to fix existing class field values. If one has got to the point where the validation error message appears, it's not no longer possible to save the menu item, and there is no way to fix this except for maybe deleting the field. Due to this, I would consider this a Major issue.</p>
issue