-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
a11y: Tree with checkboxes expands node instead of checking checkbox for SPACE
key
#7132
Comments
Seems to be caused by a missing |
Have you fixed your issue? |
Yes, I've fixed it locally for my tree, but from accessibility perspective the two examples from https://mantine.dev/core/tree/#checked-state are wrong:
Here's a quick outline on what I did to fix this:
The remains kind of a problem, that In the end the code looks something like this: import { IconChevronDown } from "@tabler/icons-react";
import {
Button,
Checkbox,
Group,
RenderTreeNodePayload,
Tree,
} from "@mantine/core";
import { data } from "./data";
const renderTreeNode = ({
node,
expanded,
hasChildren,
elementProps,
tree,
}: RenderTreeNodePayload) => {
const checked = tree.isNodeChecked(node.value);
const indeterminate = tree.isNodeIndeterminate(node.value);
return (
<Group gap="xs" {...elementProps}>
<Checkbox
checked={checked}
indeterminate={indeterminate}
onChange={() =>
!checked ? tree.checkNode(node.value) : tree.uncheckNode(node.value)
}
label={node.label}
/>
{hasChildren && (
<Button
title={expanded ? "Close" : "Open"}
onClick={() => tree.toggleExpanded(node.value)}
>
<IconChevronDown
size={14}
style={{
transform: expanded ? "rotate(180deg)" : "rotate(0deg)",
}}
/>
</Button>
)}
</Group>
);
};
function Demo() {
return (
<Tree
data={data}
levelOffset={23}
expandOnClick={false}
expandOnSpace={false}
renderNode={renderTreeNode}
/>
);
} |
Fixed in 7.14.3 |
Dependencies check up
What version of @mantine/* packages do you have in package.json?
7.14.1
What package has an issue?
@mantine/core
What framework do you use?
Next.js
In which browsers you can reproduce the issue?
All
Describe the bug
Steps to reproduce:
TAB
until you focus any of the tree`s checkboxesSPACE
barExpected result:
The checkbox should be checked or unchecked
Actual result:
The checkbox is not affected at all but instead the tree is expanded.
I have this problem locally too but I guess it is easier for reproduction if you just use the official example.
If possible, include a link to a codesandbox with a minimal reproduction
No response
Possible fix
No response
Self-service
The text was updated successfully, but these errors were encountered: