modified combobox to handle error class

This commit is contained in:
David Kennedy 2025-01-14 20:56:45 -05:00
parent 24e0243df3
commit fabeddaa61
No known key found for this signature in database
GPG key ID: 6528A5386E66B96B

View file

@ -31,6 +31,7 @@
* - fixed bug in createHeaderButton which added newlines to header button tooltips
* - modified combobox to allow for blank values in list
* - modified aria label for X button in combobox to reflect modified behavior of button
* - modified combobox to handle error class
*/
if ("document" in window.self) {
@ -1223,6 +1224,11 @@ const enhanceComboBox = _comboBoxEl => {
input.setAttribute("class", INPUT_CLASS);
input.setAttribute("type", "text");
input.setAttribute("role", "combobox");
// DOTGOV - handle error class for combobox
// Check if 'usa-input--error' exists in selectEl and add it to input if true
if (selectEl.classList.contains('usa-input--error')) {
input.classList.add('usa-input--error');
}
additionalAttributes.forEach(attr => Object.keys(attr).forEach(key => {
const value = Sanitizer.escapeHTML`${attr[key]}`;
input.setAttribute(key, value);