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 @@ -97,6 +97,14 @@ export const ChatbotHeaderPinDemo: FunctionComponent = () => {
}
return newPinned;
});

// Focus the conversation input after pin/unpin action
setTimeout(() => {
const dropdown = document.getElementById(`pin-demo-${conversationId}-dropdown`);
if (dropdown) {
dropdown.focus();
}
}, 100);
};

const createMenuItems = (conversationId: string) => {
Expand Down Expand Up @@ -136,7 +144,8 @@ export const ChatbotHeaderPinDemo: FunctionComponent = () => {
pinnedItems.push({
...conv,
menuItems: createMenuItems(conv.id),
icon: <ThumbtackIcon />
icon: <ThumbtackIcon />,
dropdownId: `pin-demo-${conv.id}-dropdown`
});
}
});
Expand All @@ -153,7 +162,8 @@ export const ChatbotHeaderPinDemo: FunctionComponent = () => {
.filter((conv) => !pinnedConversations.has(conv.id))
.map((conv) => ({
...conv,
menuItems: createMenuItems(conv.id)
menuItems: createMenuItems(conv.id),
dropdownId: `pin-demo-${conv.id}-dropdown`
}));

if (unpinnedConversations.length > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,16 @@ export interface ChatbotConversationHistoryDropdownProps extends Omit<DropdownPr
label?: string;
/** Callback for when user selects item. */
onSelect?: (event?: React.MouseEvent, value?: string | number) => void;
/** Id applied to dropdown menu toggle */
id?: string;
}

export const ChatbotConversationHistoryDropdown: FunctionComponent<ChatbotConversationHistoryDropdownProps> = ({
menuItems,
menuClassName,
onSelect,
label
label,
id
}: ChatbotConversationHistoryDropdownProps) => {
const [isOpen, setIsOpen] = useState(false);

Expand All @@ -44,6 +47,7 @@ export const ChatbotConversationHistoryDropdown: FunctionComponent<ChatbotConver
ref={toggleRef}
isExpanded={isOpen}
onClick={() => setIsOpen(!isOpen)}
id={id}
>
<EllipsisIcon />
</MenuToggle>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ export interface Conversation {
additionalProps?: ButtonProps;
/** Additional props passed to conversation list item */
listItemProps?: Omit<ListItemProps, 'children'>;
/** Custom dropdown ID to ensure uniqueness across demo instances */
dropdownId?: string;
}
export interface ChatbotConversationHistoryNavProps extends DrawerProps {
/** Function called to toggle drawer */
Expand Down Expand Up @@ -202,6 +204,7 @@ export const ChatbotConversationHistoryNav: FunctionComponent<ChatbotConversatio
onSelect={conversation.onSelect}
menuItems={conversation.menuItems}
label={conversation.label}
id={conversation.dropdownId}
/>
)}
</>
Expand Down
Loading