@@ -6,7 +6,7 @@ import { CollapseContext } from "helpers/contexts";
66import Toggle from "./Toggle" ;
77import 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";
5758Collapse . 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