Merge pull request #22908 from overleaf/mf-fix-disable-element-bs5-anchor-tag

[web] Fix `disableElement` won't properly disable the element if using bs5 and applied on anchor tag

GitOrigin-RevId: 49ce8514be3e44e5e3a45f41751c94c77f34399b
This commit is contained in:
M Fahru
2025-05-19 10:52:31 -07:00
committed by Copybot
parent 2d7de079d5
commit e054fe8ede

View File

@@ -1,9 +1,19 @@
import { isBootstrap5 } from './bootstrap-5'
export function disableElement(el) {
el.setAttribute('disabled', '')
if (isBootstrap5() && el.tagName.toLowerCase() === 'a') {
el.classList.add('disabled')
} else {
el.disabled = true
}
el.setAttribute('aria-disabled', 'true')
}
export function enableElement(el) {
el.removeAttribute('disabled')
if (isBootstrap5() && el.tagName.toLowerCase() === 'a') {
el.classList.remove('disabled')
} else {
el.disabled = false
}
el.removeAttribute('aria-disabled')
}