Skip to content

Commit

Permalink
fix: fix issue in Firefox where disabled elements were incorrectly en…
Browse files Browse the repository at this point in the history
…abled when a sibling was enabled (#9710)
  • Loading branch information
jcfranco authored and github-actions[bot] committed Jun 28, 2024
1 parent 99a4f82 commit cd4d52c
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion packages/calcite-components/src/utils/interactive.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,31 @@ function getParentElement(component: InteractiveComponent): ParentElement {
); /* assume element is host if it has no parent when connected */
}

function isInteractiveHTMLElement(el: Element): el is InteractiveHTMLElement {
return "disabled" in el;
}

function restoreInteraction(component: InteractiveComponent): void {
delete component.el.click; // fallback on HTMLElement.prototype.click

if (isFirefox) {
removeInteractionListeners(disabledElementToParent.get(component.el));
const parent = disabledElementToParent.get(component.el);

let hasDisabledSiblingElements = false;

if (parent?.children) {
for (const child of parent.children) {
if (isInteractiveHTMLElement(child) && child.disabled && child !== component.el) {
hasDisabledSiblingElements = true;
break;
}
}
}

if (!hasDisabledSiblingElements) {
removeInteractionListeners(parent);
}

disabledElementToParent.delete(component.el);
return;
}
Expand Down

0 comments on commit cd4d52c

Please sign in to comment.