Skip to content

Commit a772c6d

Browse files
authored
fix(TreeView): define button type (#9770)
1 parent 4f459eb commit a772c6d

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
@@ -135,6 +135,7 @@ const TreeViewListItemBase: React.FunctionComponent<TreeViewListItemProps> = ({
135135
}
136136
}}
137137
{...((hasCheckbox || isSelectable) && { 'aria-labelledby': `label-${randomId}` })}
138+
{...(ToggleComponent === 'button' && { type: 'button' })}
138139
tabIndex={-1}
139140
>
140141
<span className={css(styles.treeViewNodeToggleIcon)}>
@@ -167,7 +168,7 @@ const TreeViewListItemBase: React.FunctionComponent<TreeViewListItemProps> = ({
167168
<>
168169
{isCompact && title && <span className={css(styles.treeViewNodeTitle)}>{title}</span>}
169170
{isSelectable ? (
170-
<button tabIndex={-1} className={css(styles.treeViewNodeText)}>
171+
<button tabIndex={-1} className={css(styles.treeViewNodeText)} type="button">
171172
{name}
172173
</button>
173174
) : (
@@ -230,6 +231,7 @@ const TreeViewListItemBase: React.FunctionComponent<TreeViewListItemProps> = ({
230231
}}
231232
{...(hasCheckbox && { htmlFor: randomId })}
232233
{...((hasCheckbox || (isSelectable && children)) && { id: `label-${randomId}` })}
234+
{...(Component === 'button' && { type: 'button' })}
233235
>
234236
<span className={css(styles.treeViewNodeContainer)}>
235237
{children && renderToggle(randomId)}

0 commit comments

Comments
 (0)