Skip to content

Commit a5544b0

Browse files
feat(ChatbotConversationHistoryNav): add history drawer title with icon (#588)
ChatBot user testing in Q1 2025 revealed that many users had trouble identifying the purpose of the chat history drawer. Design suggested adding a title to make this clearer to users. Title can be customized as needed. Co-authored-by: Rebecca Alpert <ralpert@redhat.com>
1 parent 1f15f3e commit a5544b0

3 files changed

Lines changed: 79 additions & 13 deletions

File tree

packages/module/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.scss

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,22 @@
99
// Drawer input
1010
// ----------------------------------------------------------------------------
1111
.pf-chatbot__input {
12+
}
13+
// Drawer title
14+
// ----------------------------------------------------------------------------
15+
.pf-chatbot__title-container {
1216
padding-inline-start: var(--pf-t--global--spacer--lg);
1317
padding-inline-end: var(--pf-t--global--spacer--lg);
18+
display: flex;
19+
flex-direction: column;
20+
row-gap: var(--pf-t--global--spacer--sm);
21+
}
22+
// Drawer title icon
23+
// ----------------------------------------------------------------------------
24+
.pf-chatbot__title-icon {
25+
padding-inline-end: var(--pf-t--global--spacer--md);
26+
padding-inline-start: var(--pf-t--global--spacer--sm);
1427
}
15-
1628
// Drawer menu
1729
// ----------------------------------------------------------------------------
1830
.pf-v6-c-menu {
@@ -75,7 +87,7 @@
7587
--pf-v6-c-drawer__panel--BackgroundColor: var(--pf-t--global--background--color--floating--default);
7688
--pf-v6-c-drawer__panel--PaddingBlockStart: var(--pf-t--global--spacer--lg);
7789
--pf-v6-c-drawer__panel--PaddingBlockEnd: var(--pf-t--global--spacer--lg);
78-
--pf-v6-c-drawer__panel--RowGap: var(--pf-t--global--spacer--lg);
90+
--pf-v6-c-drawer__panel--RowGap: var(--pf-t--global--spacer--gap--group-to-group--vertical--default);
7991
overflow-x: hidden;
8092
overflow-y: hidden;
8193
}

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

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,4 +433,45 @@ describe('ChatbotConversationHistoryNav', () => {
433433
);
434434
expect(screen.getByTestId('drawer')).toHaveClass('pf-m-compact');
435435
});
436+
437+
it('should display the default title', () => {
438+
render(
439+
<ChatbotConversationHistoryNav
440+
onDrawerToggle={onDrawerToggle}
441+
isDrawerOpen={true}
442+
displayMode={ChatbotDisplayMode.fullscreen}
443+
setIsDrawerOpen={jest.fn()}
444+
conversations={initialConversations}
445+
/>
446+
);
447+
expect(screen.getByText('Chat history')).toBeInTheDocument();
448+
});
449+
450+
it('should display the custom title', () => {
451+
render(
452+
<ChatbotConversationHistoryNav
453+
title="PatternFly history"
454+
onDrawerToggle={onDrawerToggle}
455+
isDrawerOpen={true}
456+
displayMode={ChatbotDisplayMode.fullscreen}
457+
setIsDrawerOpen={jest.fn()}
458+
conversations={initialConversations}
459+
/>
460+
);
461+
expect(screen.getByText('PatternFly history')).toBeInTheDocument();
462+
});
463+
464+
it('should display the clock icon', () => {
465+
const { container } = render(
466+
<ChatbotConversationHistoryNav
467+
onDrawerToggle={onDrawerToggle}
468+
isDrawerOpen={true}
469+
displayMode={ChatbotDisplayMode.fullscreen}
470+
setIsDrawerOpen={jest.fn()}
471+
conversations={initialConversations}
472+
/>
473+
);
474+
const iconElement = container.querySelector('.pf-chatbot__title-icon');
475+
expect(iconElement).toBeInTheDocument();
476+
});
436477
});

packages/module/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.tsx

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,12 @@ import {
3232
DrawerActionsProps,
3333
DrawerCloseButtonProps,
3434
DrawerPanelBodyProps,
35-
SkeletonProps
35+
SkeletonProps,
36+
Title,
37+
Icon
3638
} from '@patternfly/react-core';
3739

38-
import { OutlinedCommentAltIcon } from '@patternfly/react-icons';
40+
import { OutlinedClockIcon, OutlinedCommentAltIcon } from '@patternfly/react-icons';
3941
import { ChatbotDisplayMode } from '../Chatbot/Chatbot';
4042
import ConversationHistoryDropdown from './ChatbotConversationHistoryDropdown';
4143
import LoadingState from './LoadingState';
@@ -120,6 +122,8 @@ export interface ChatbotConversationHistoryNavProps extends DrawerProps {
120122
noResultsState?: HistoryEmptyStateProps;
121123
/** Sets drawer to compact styling. */
122124
isCompact?: boolean;
125+
/** Display title */
126+
title?: string;
123127
}
124128

125129
export const ChatbotConversationHistoryNav: FunctionComponent<ChatbotConversationHistoryNavProps> = ({
@@ -152,6 +156,7 @@ export const ChatbotConversationHistoryNav: FunctionComponent<ChatbotConversatio
152156
emptyState,
153157
noResultsState,
154158
isCompact,
159+
title = 'Chat history',
155160
...props
156161
}: ChatbotConversationHistoryNavProps) => {
157162
const drawerRef = useRef<HTMLDivElement>(null);
@@ -238,15 +243,6 @@ export const ChatbotConversationHistoryNav: FunctionComponent<ChatbotConversatio
238243

239244
const renderDrawerContent = () => (
240245
<>
241-
{handleTextInputChange && (
242-
<div className="pf-chatbot__input">
243-
<SearchInput
244-
aria-label={searchInputAriaLabel}
245-
onChange={(_event, value) => handleTextInputChange(value)}
246-
placeholder={searchInputPlaceholder}
247-
/>
248-
</div>
249-
)}
250246
<DrawerPanelBody {...drawerPanelBodyProps}>{renderMenuContent()}</DrawerPanelBody>
251247
</>
252248
);
@@ -268,6 +264,23 @@ export const ChatbotConversationHistoryNav: FunctionComponent<ChatbotConversatio
268264
)}
269265
</DrawerActions>
270266
</DrawerHead>
267+
<div className="pf-chatbot__title-container">
268+
<Title headingLevel="h3">
269+
<Icon size="lg" className="pf-chatbot__title-icon">
270+
<OutlinedClockIcon />
271+
</Icon>
272+
{title}
273+
</Title>
274+
{!isLoading && handleTextInputChange && (
275+
<div className="pf-chatbot__input">
276+
<SearchInput
277+
aria-label={searchInputAriaLabel}
278+
onChange={(_event, value) => handleTextInputChange(value)}
279+
placeholder={searchInputPlaceholder}
280+
/>
281+
</div>
282+
)}
283+
</div>
271284
{isLoading ? <LoadingState {...loadingState} /> : renderDrawerContent()}
272285
</>
273286
);

0 commit comments

Comments
 (0)