Skip to content

Commit b71c16d

Browse files
fix(ChatbotConversationHistoryNav): Pass search input props (#630)
Allow for controlled inputs and other customizations by passing props down.
1 parent 900c0d0 commit b71c16d

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,4 +561,20 @@ describe('ChatbotConversationHistoryNav', () => {
561561
);
562562
expect(screen.getByRole('listitem')).toHaveClass('test');
563563
});
564+
565+
it('should be able to spread search input props when searchInputProps is passed', () => {
566+
render(
567+
<ChatbotConversationHistoryNav
568+
onDrawerToggle={onDrawerToggle}
569+
isDrawerOpen={true}
570+
displayMode={ChatbotDisplayMode.fullscreen}
571+
setIsDrawerOpen={jest.fn()}
572+
conversations={initialConversations}
573+
handleTextInputChange={jest.fn()}
574+
searchInputProps={{ value: 'I am a sample search' }}
575+
/>
576+
);
577+
578+
expect(screen.getByRole('dialog', { name: /Chat history I am a sample search/i })).toBeInTheDocument();
579+
});
564580
});

packages/module/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ import {
3434
Icon,
3535
MenuProps, // Remove in next breaking change
3636
TitleProps,
37-
ListProps
37+
ListProps,
38+
SearchInputProps
3839
} from '@patternfly/react-core';
3940

4041
import { OutlinedClockIcon, OutlinedCommentAltIcon, PenToSquareIcon } from '@patternfly/react-icons';
@@ -94,6 +95,8 @@ export interface ChatbotConversationHistoryNavProps extends DrawerProps {
9495
searchInputPlaceholder?: string;
9596
/** Aria label for search input */
9697
searchInputAriaLabel?: string;
98+
/** Additional props passed to search input */
99+
searchInputProps?: SearchInputProps;
97100
/** A callback for when the input value changes. Omit to hide input field */
98101
handleTextInputChange?: (value: string) => void;
99102
/** Display mode of chatbot */
@@ -149,6 +152,7 @@ export const ChatbotConversationHistoryNav: FunctionComponent<ChatbotConversatio
149152
newChatButtonProps,
150153
searchInputPlaceholder = 'Search previous conversations...',
151154
searchInputAriaLabel = 'Filter menu items',
155+
searchInputProps,
152156
handleTextInputChange,
153157
displayMode,
154158
reverseButtonOrder = false,
@@ -292,6 +296,7 @@ export const ChatbotConversationHistoryNav: FunctionComponent<ChatbotConversatio
292296
aria-label={searchInputAriaLabel}
293297
onChange={(_event, value) => handleTextInputChange(value)}
294298
placeholder={searchInputPlaceholder}
299+
{...searchInputProps}
295300
/>
296301
</div>
297302
)}

0 commit comments

Comments
 (0)