Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix issue in Firefox where disabled elements were incorrectly enabled when a sibling was enabled #9710

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading