Skip to content

Commit

Permalink
v4 - add button type to TreeView (#9779)
Browse files Browse the repository at this point in the history
  • Loading branch information
kmcfaul authored Nov 2, 2023
1 parent 388ec12 commit a42935c
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ const TreeViewListItemBase: React.FunctionComponent<TreeViewListItemProps> = ({
}
}}
{...((hasCheck || isSelectable) && { 'aria-labelledby': `label-${randomId}` })}
{...(ToggleComponent === 'button' && { type: 'button' })}
tabIndex={-1}
>
<span className={css(styles.treeViewNodeToggleIcon)}>
Expand Down Expand Up @@ -156,7 +157,7 @@ const TreeViewListItemBase: React.FunctionComponent<TreeViewListItemProps> = ({
<>
{isCompact && title && <span className={css(styles.treeViewNodeTitle)}>{title}</span>}
{isSelectable ? (
<button tabIndex={-1} className={css(styles.treeViewNodeText)}>
<button tabIndex={-1} className={css(styles.treeViewNodeText)} type="button">
{name}
</button>
) : (
Expand Down Expand Up @@ -214,6 +215,7 @@ const TreeViewListItemBase: React.FunctionComponent<TreeViewListItemProps> = ({
}}
{...(hasCheck && { htmlFor: randomId })}
{...((hasCheck || (isSelectable && children)) && { id: `label-${randomId}` })}
{...(Component === 'button' && { type: 'button' })}
>
<span className={css(styles.treeViewNodeContainer)}>
{children && renderToggle(randomId)}
Expand Down
Loading

0 comments on commit a42935c

Please sign in to comment.