overleaf-cep/services/web/frontend/js/features/utils/disableElement.js
M Fahru 14d6600fb5 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
2025-05-20 08:06:26 +00:00

19 lines
471 B
JavaScript

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