Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
it('should display the dropdown menuItems', () => {
render(<ChatbotConversationHistoryDropdown menuItems={menuItems} />);

const toggle = screen.queryByRole('menuitem', { name: /Conversation options/i })!;

Check warning on line 23 in packages/module/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.test.tsx

View workflow job for this annotation

GitHub Actions / call-build-lint-test-workflow / lint

Forbidden non-null assertion

expect(toggle).toBeInTheDocument();
fireEvent.click(toggle);
Expand All @@ -33,7 +33,7 @@

it('should invoke onSelect callback when menuitem is clicked', () => {
render(<ChatbotConversationHistoryDropdown menuItems={menuItems} onSelect={onSelect} />);
const toggle = screen.queryByRole('menuitem', { name: /Conversation options/i })!;

Check warning on line 36 in packages/module/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.test.tsx

View workflow job for this annotation

GitHub Actions / call-build-lint-test-workflow / lint

Forbidden non-null assertion
fireEvent.click(toggle);
fireEvent.click(screen.getByText('Rename'));

Expand Down Expand Up @@ -78,4 +78,9 @@
expect(screen.queryByText('Actions dropdown')).toBeInTheDocument();
});
});

it('should be able to set a custom aria-label', () => {
render(<ChatbotConversationHistoryDropdown menuItems={menuItems} aria-label="Custom conversation options" />);
expect(screen.queryByRole('menuitem', { name: /Custom conversation options/i })).toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ export interface ChatbotConversationHistoryDropdownProps extends Omit<DropdownPr
menuItems: React.ReactNode;
/** Optional classname applied to conversation settings dropdown */
menuClassName?: string;
/** Tooltip content and aria-label applied to conversation settings dropdown */
/** Tooltip content applied to conversation settings dropdown */
label?: string;
/** Aria-label applied to conversation settings dropdown */
'aria-label'?: string;
/** Callback for when user selects item. */
onSelect?: (event?: React.MouseEvent, value?: string | number) => void;
/** Id applied to dropdown menu toggle */
Expand All @@ -27,23 +29,24 @@ export const ChatbotConversationHistoryDropdown: FunctionComponent<ChatbotConver
menuItems,
menuClassName,
onSelect,
label,
label = 'Conversation options',
'aria-label': ariaLabel,
id
}: ChatbotConversationHistoryDropdownProps) => {
const [isOpen, setIsOpen] = useState(false);

const toggle = (toggleRef: Ref<MenuToggleElement>) => (
<Tooltip
className="pf-chatbot__tooltip"
content={label ?? 'Conversation options'}
content={label}
position="bottom"
// prevents VO announcements of both aria label and tooltip
aria="none"
>
<MenuToggle
className="pf-chatbot__history-actions"
variant="plain"
aria-label={label ?? 'Conversation options'}
aria-label={ariaLabel ?? label}
ref={toggleRef}
isExpanded={isOpen}
onClick={() => setIsOpen(!isOpen)}
Expand Down
Loading