File tree Expand file tree Collapse file tree 1 file changed +29
-11
lines changed
packages/react-core/src/components/DescriptionList Expand file tree Collapse file tree 1 file changed +29
-11
lines changed Original file line number Diff line number Diff line change @@ -13,15 +13,33 @@ export const DescriptionListTermHelpTextButton: React.FunctionComponent<Descript
1313 children,
1414 className,
1515 ...props
16- } : DescriptionListTermHelpTextButtonProps ) => (
17- < span
18- className = { css ( className , styles . descriptionListText , styles . modifiers . helpText ) }
19- role = "button"
20- type = "button"
21- tabIndex = { 0 }
22- { ...props }
23- >
24- { children }
25- </ span >
26- ) ;
16+ } : DescriptionListTermHelpTextButtonProps ) => {
17+ const helpTextRef = React . createRef < HTMLSpanElement > ( ) ;
18+
19+ const handleKeys = ( event : React . KeyboardEvent < HTMLSpanElement > ) => {
20+ if ( ! helpTextRef . current || helpTextRef . current !== ( event . target as HTMLElement ) ) {
21+ return ;
22+ }
23+
24+ const key = event . key ;
25+ if ( key === 'Enter' || key === ' ' ) {
26+ event . preventDefault ( ) ;
27+ helpTextRef . current . click ( ) ;
28+ }
29+ } ;
30+
31+ return (
32+ < span
33+ ref = { helpTextRef }
34+ className = { css ( className , styles . descriptionListText , styles . modifiers . helpText ) }
35+ role = "button"
36+ type = "button"
37+ tabIndex = { 0 }
38+ onKeyDown = { ( event ) => handleKeys ( event ) }
39+ { ...props }
40+ >
41+ { children }
42+ </ span >
43+ ) ;
44+ } ;
2745DescriptionListTermHelpTextButton . displayName = 'DescriptionListTermHelpTextButton' ;
You can’t perform that action at this time.
0 commit comments