File tree Expand file tree Collapse file tree 3 files changed +28
-12
lines changed
Expand file tree Collapse file tree 3 files changed +28
-12
lines changed Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ export interface AttachMenuProps extends DropdownProps {
2121 /** Items in menu */
2222 filteredItems : React . ReactNode ;
2323 /** A callback for when the input value changes. */
24- handleTextInputChange : ( value : string ) => void ;
24+ handleTextInputChange ? : ( value : string ) => void ;
2525 /** Flag to indicate if menu is opened. */
2626 isOpen : boolean ;
2727 /** Additional properties to pass to the Popper */
@@ -73,16 +73,18 @@ export const AttachMenu: FunctionComponent<AttachMenuProps> = ({
7373 onSelect = { onSelect }
7474 { ...props }
7575 >
76- < MenuSearch { ...menuSearchProps } >
77- < MenuSearchInput { ...menuSearchInputProps } >
78- < SearchInput
79- aria-label = { searchInputAriaLabel }
80- onChange = { ( _event , value ) => handleTextInputChange ( value ) }
81- placeholder = { searchInputPlaceholder }
82- { ...searchInputProps }
83- />
84- </ MenuSearchInput >
85- </ MenuSearch >
76+ { handleTextInputChange && (
77+ < MenuSearch { ...menuSearchProps } >
78+ < MenuSearchInput { ...menuSearchInputProps } >
79+ < SearchInput
80+ aria-label = { searchInputAriaLabel }
81+ onChange = { ( _event , value ) => handleTextInputChange ( value ) }
82+ placeholder = { searchInputPlaceholder }
83+ { ...searchInputProps }
84+ />
85+ </ MenuSearchInput >
86+ </ MenuSearch >
87+ ) }
8688 { filteredItems }
8789 </ Dropdown >
8890) ;
Original file line number Diff line number Diff line change @@ -275,6 +275,20 @@ describe('Message bar', () => {
275275 ) ;
276276 expect ( screen . getByTestId ( 'menu-search-input' ) ) . toBeTruthy ( ) ;
277277 } ) ;
278+ it ( 'can remove input from attach menu' , async ( ) => {
279+ render (
280+ < MessageBar
281+ onSendMessage = { jest . fn }
282+ attachMenuProps = { {
283+ isAttachMenuOpen : true ,
284+ setIsAttachMenuOpen : jest . fn ( ) ,
285+ onAttachMenuToggleClick : jest . fn ( ) ,
286+ attachMenuItems : ATTACH_MENU_ITEMS
287+ } }
288+ />
289+ ) ;
290+ expect ( screen . queryByRole ( 'textbox' , { name : / F i l t e r m e n u i t e m s / i } ) ) . not . toBeInTheDocument ( ) ;
291+ } ) ;
278292 it ( 'can hide attach button' , ( ) => {
279293 render ( < MessageBar onSendMessage = { jest . fn } hasAttachButton = { false } /> ) ;
280294 expect ( screen . queryByRole ( 'button' , { name : 'Attach' } ) ) . toBeFalsy ( ) ;
Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ export interface MessageBarWithAttachMenuProps {
2929 /** A callback for when the attachment menu toggle is clicked */
3030 onAttachMenuToggleClick : ( ) => void ;
3131 /** A callback for when the input value in the menu changes. */
32- onAttachMenuInputChange : ( value : string ) => void ;
32+ onAttachMenuInputChange ? : ( value : string ) => void ;
3333 /** Function callback called when user selects item in menu. */
3434 onAttachMenuSelect ?: ( event ?: React . MouseEvent < Element , MouseEvent > , value ?: string | number ) => void ;
3535 /** Placeholder for search input */
You can’t perform that action at this time.
0 commit comments