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
24 changes: 13 additions & 11 deletions packages/module/src/AttachMenu/AttachMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
/** Items in menu */
filteredItems: React.ReactNode;
/** A callback for when the input value changes. */
handleTextInputChange: (value: string) => void;
handleTextInputChange?: (value: string) => void;
/** Flag to indicate if menu is opened. */
isOpen: boolean;
/** Additional properties to pass to the Popper */
Expand All @@ -37,7 +37,7 @@
/** Aria label for search input */
searchInputAriaLabel?: string;
/** Toggle to be rendered */
toggle: DropdownToggleProps | ((toggleRef: React.RefObject<any>) => React.ReactNode);

Check warning on line 40 in packages/module/src/AttachMenu/AttachMenu.tsx

View workflow job for this annotation

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

Unexpected any. Specify a different type
/** Additional props passed to MenuSearch component */
menuSearchProps?: Omit<MenuSearchProps, 'ref'>;
/** Additional props passed to MenuSearchInput component */
Expand Down Expand Up @@ -73,16 +73,18 @@
onSelect={onSelect}
{...props}
>
<MenuSearch {...menuSearchProps}>
<MenuSearchInput {...menuSearchInputProps}>
<SearchInput
aria-label={searchInputAriaLabel}
onChange={(_event, value) => handleTextInputChange(value)}
placeholder={searchInputPlaceholder}
{...searchInputProps}
/>
</MenuSearchInput>
</MenuSearch>
{handleTextInputChange && (
<MenuSearch {...menuSearchProps}>
<MenuSearchInput {...menuSearchInputProps}>
<SearchInput
aria-label={searchInputAriaLabel}
onChange={(_event, value) => handleTextInputChange(value)}
placeholder={searchInputPlaceholder}
{...searchInputProps}
/>
</MenuSearchInput>
</MenuSearch>
)}
{filteredItems}
</Dropdown>
);
Expand Down
14 changes: 14 additions & 0 deletions packages/module/src/MessageBar/MessageBar.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,20 @@ describe('Message bar', () => {
);
expect(screen.getByTestId('menu-search-input')).toBeTruthy();
});
it('can remove input from attach menu', async () => {
render(
<MessageBar
onSendMessage={jest.fn}
attachMenuProps={{
isAttachMenuOpen: true,
setIsAttachMenuOpen: jest.fn(),
onAttachMenuToggleClick: jest.fn(),
attachMenuItems: ATTACH_MENU_ITEMS
}}
/>
);
expect(screen.queryByRole('textbox', { name: /Filter menu items/i })).not.toBeInTheDocument();
});
it('can hide attach button', () => {
render(<MessageBar onSendMessage={jest.fn} hasAttachButton={false} />);
expect(screen.queryByRole('button', { name: 'Attach' })).toBeFalsy();
Expand Down
2 changes: 1 addition & 1 deletion packages/module/src/MessageBar/MessageBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export interface MessageBarWithAttachMenuProps {
/** A callback for when the attachment menu toggle is clicked */
onAttachMenuToggleClick: () => void;
/** A callback for when the input value in the menu changes. */
onAttachMenuInputChange: (value: string) => void;
onAttachMenuInputChange?: (value: string) => void;
/** Function callback called when user selects item in menu. */
onAttachMenuSelect?: (event?: React.MouseEvent<Element, MouseEvent>, value?: string | number) => void;
/** Placeholder for search input */
Expand Down
Loading