Skip to content

Commit a42935c

Browse files
authored
v4 - add button type to TreeView (#9779)
1 parent 388ec12 commit a42935c

File tree

2 files changed

+63
-1
lines changed

2 files changed

+63
-1
lines changed

packages/react-core/src/components/TreeView/TreeViewListItem.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ const TreeViewListItemBase: React.FunctionComponent<TreeViewListItemProps> = ({
124124
}
125125
}}
126126
{...((hasCheck || isSelectable) && { 'aria-labelledby': `label-${randomId}` })}
127+
{...(ToggleComponent === 'button' && { type: 'button' })}
127128
tabIndex={-1}
128129
>
129130
<span className={css(styles.treeViewNodeToggleIcon)}>
@@ -156,7 +157,7 @@ const TreeViewListItemBase: React.FunctionComponent<TreeViewListItemProps> = ({
156157
<>
157158
{isCompact && title && <span className={css(styles.treeViewNodeTitle)}>{title}</span>}
158159
{isSelectable ? (
159-
<button tabIndex={-1} className={css(styles.treeViewNodeText)}>
160+
<button tabIndex={-1} className={css(styles.treeViewNodeText)} type="button">
160161
{name}
161162
</button>
162163
) : (
@@ -214,6 +215,7 @@ const TreeViewListItemBase: React.FunctionComponent<TreeViewListItemProps> = ({
214215
}}
215216
{...(hasCheck && { htmlFor: randomId })}
216217
{...((hasCheck || (isSelectable && children)) && { id: `label-${randomId}` })}
218+
{...(Component === 'button' && { type: 'button' })}
217219
>
218220
<span className={css(styles.treeViewNodeContainer)}>
219221
{children && renderToggle(randomId)}

0 commit comments

Comments
 (0)