Skip to content

Commit 9efa451

Browse files
fix(ChatbotConversationHistoryDropdown): Add separate prop for aria label (#684)
1 parent f3314cb commit 9efa451

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

packages/module/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.test.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,9 @@ describe('ChatbotConversationHistoryDropdown', () => {
7878
expect(screen.queryByText('Actions dropdown')).toBeInTheDocument();
7979
});
8080
});
81+
82+
it('should be able to set a custom aria-label', () => {
83+
render(<ChatbotConversationHistoryDropdown menuItems={menuItems} aria-label="Custom conversation options" />);
84+
expect(screen.queryByRole('menuitem', { name: /Custom conversation options/i })).toBeInTheDocument();
85+
});
8186
});

packages/module/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ export interface ChatbotConversationHistoryDropdownProps extends Omit<DropdownPr
1515
menuItems: React.ReactNode;
1616
/** Optional classname applied to conversation settings dropdown */
1717
menuClassName?: string;
18-
/** Tooltip content and aria-label applied to conversation settings dropdown */
18+
/** Tooltip content applied to conversation settings dropdown */
1919
label?: string;
20+
/** Aria-label applied to conversation settings dropdown */
21+
'aria-label'?: string;
2022
/** Callback for when user selects item. */
2123
onSelect?: (event?: React.MouseEvent, value?: string | number) => void;
2224
/** Id applied to dropdown menu toggle */
@@ -27,23 +29,24 @@ export const ChatbotConversationHistoryDropdown: FunctionComponent<ChatbotConver
2729
menuItems,
2830
menuClassName,
2931
onSelect,
30-
label,
32+
label = 'Conversation options',
33+
'aria-label': ariaLabel,
3134
id
3235
}: ChatbotConversationHistoryDropdownProps) => {
3336
const [isOpen, setIsOpen] = useState(false);
3437

3538
const toggle = (toggleRef: Ref<MenuToggleElement>) => (
3639
<Tooltip
3740
className="pf-chatbot__tooltip"
38-
content={label ?? 'Conversation options'}
41+
content={label}
3942
position="bottom"
4043
// prevents VO announcements of both aria label and tooltip
4144
aria="none"
4245
>
4346
<MenuToggle
4447
className="pf-chatbot__history-actions"
4548
variant="plain"
46-
aria-label={label ?? 'Conversation options'}
49+
aria-label={ariaLabel ?? label}
4750
ref={toggleRef}
4851
isExpanded={isOpen}
4952
onClick={() => setIsOpen(!isOpen)}

0 commit comments

Comments
 (0)