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-20 08:06:26 +00:00
committed by Copybot
parent d8c5b74e09
commit 14d6600fb5
@@ -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')
}