Skip to content

Commit 7c424fd

Browse files
committed
[B] Fix inert logic on collapsed content
1 parent 08c89ed commit 7c424fd

File tree

1 file changed

+5
-3
lines changed
  • client/src/global/components/Collapse

1 file changed

+5
-3
lines changed

client/src/global/components/Collapse/index.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { CollapseContext } from "helpers/contexts";
66
import Toggle from "./Toggle";
77
import Content from "./Content";
88

9-
function Collapse({ initialVisible, children, stubHeight }) {
9+
function Collapse({ initialVisible, children, stubHeight, label }) {
1010
const [visible, setVisible] = useState(initialVisible);
1111
const toggleVisible = () => setVisible(!visible);
1212
const idSeed = useUIDSeed();
@@ -23,8 +23,9 @@ function Collapse({ initialVisible, children, stubHeight }) {
2323
const contentProps = {
2424
id: idSeed("content"),
2525
role: "region",
26-
"aria-labelledby": idSeed("label"),
27-
inert: !visible && stubHeight < height ? "" : undefined,
26+
"aria-label": label,
27+
"aria-labelledby": !label ? idSeed("label") : undefined,
28+
inert: !visible && (!stubHeight || stubHeight < height) ? "" : undefined,
2829
resizeRef
2930
};
3031

@@ -57,6 +58,7 @@ Collapse.displayName = "Global.Collapse";
5758
Collapse.propTypes = {
5859
initialVisible: PropTypes.bool,
5960
stubHeight: PropTypes.number,
61+
label: PropTypes.string,
6062
children: PropTypes.oneOfType([PropTypes.string, PropTypes.node])
6163
};
6264

0 commit comments

Comments
 (0)