Skip to content

Commit 696773e

Browse files
authored
Merge pull request #5907 from dfsmania/fix_accessibility_validations
Fix accessibility validations conflicting with Bootstrap
2 parents 45f7a1f + ff2bd37 commit 696773e

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

src/scss/_accessibility.scss

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,6 @@
159159
}
160160

161161
.invalid-feedback {
162-
display: block;
163-
width: 100%;
164-
margin-top: .25rem;
165-
font-size: .875em;
166-
color: var(--bs-danger);
167-
168162
&[role="alert"] {
169163
font-weight: 600;
170164
}

src/ts/accessibility.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -338,10 +338,13 @@ export class AccessibilityManager {
338338
}
339339
}
340340

341-
// Handle invalid states
342-
htmlInput.addEventListener('invalid', () => {
343-
this.handleFormError(htmlInput)
344-
})
341+
// Handle invalid state unless the element explicitly opts out via the
342+
// 'disable-adminlte-validations' class.
343+
if (!htmlInput.classList.contains('disable-adminlte-validations')) {
344+
htmlInput.addEventListener('invalid', () => {
345+
this.handleFormError(htmlInput)
346+
})
347+
}
345348
})
346349
}
347350

@@ -354,7 +357,12 @@ export class AccessibilityManager {
354357
errorElement.id = errorId
355358
errorElement.className = 'invalid-feedback'
356359
errorElement.setAttribute('role', 'alert')
357-
input.parentNode?.insertBefore(errorElement, input.nextSibling)
360+
361+
// Always append the error element as the last child of the parent.
362+
// This prevents breaking layouts where inputs use Bootstrap's
363+
// `.input-group-text` decorators, ensuring the error stays below
364+
// the entire input group.
365+
input.parentNode?.append(errorElement)
358366
}
359367

360368
errorElement.textContent = input.validationMessage

0 commit comments

Comments
 (0)