Skip to content

Commit 49dc538

Browse files
author
Eric Olkowski
committed
Reverted role prop type to union
1 parent fb5b3e1 commit 49dc538

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

packages/react-core/src/components/Divider/Divider.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export interface DividerProps extends React.HTMLProps<HTMLElement> {
3232
'2xl'?: 'vertical' | 'horizontal';
3333
};
3434
/** The ARIA role of the divider when the component property has a value other than "hr". */
35-
role?: string;
35+
role?: 'separator' | 'presentation';
3636
}
3737

3838
export const Divider: React.FunctionComponent<DividerProps> = ({

packages/react-core/src/components/Toolbar/ToolbarItem.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,19 @@ export const ToolbarItem: React.FunctionComponent<ToolbarItemProps> = ({
185185
children,
186186
isAllExpanded,
187187
isOverflowContainer,
188+
role,
188189
...props
189190
}: ToolbarItemProps) => {
190191
if (variant === ToolbarItemVariant.separator) {
191-
// TODO: consider removing spread props here so we can update Divider role prop to union of
192-
// separator or presentation rather than generic string
193-
return <Divider className={css(className)} orientation={{ default: 'vertical' }} {...props} />;
192+
const isDividerRoleValid = role === 'separator' || role === 'presentation';
193+
return (
194+
<Divider
195+
className={css(className)}
196+
orientation={{ default: 'vertical' }}
197+
{...props}
198+
{...(isDividerRoleValid && { role: role as 'separator' | 'presentation' })}
199+
/>
200+
);
194201
}
195202

196203
return (
@@ -219,6 +226,7 @@ export const ToolbarItem: React.FunctionComponent<ToolbarItemProps> = ({
219226
)}
220227
{...(variant === 'label' && { 'aria-hidden': true })}
221228
id={id}
229+
role={role}
222230
{...props}
223231
>
224232
{children}

0 commit comments

Comments
 (0)