@@ -13,8 +13,10 @@ import { tokens } from '@equinor/eds-tokens';
1313
1414import {
1515 ListContainer ,
16+ ListItemSkeleton ,
1617 MenuFixedItem ,
1718 MenuItem ,
19+ MenuItemSkeletonWrapper ,
1820 MenuSection ,
1921 NoFieldsText ,
2022 NoSearchResultsContainer ,
@@ -34,6 +36,8 @@ export interface FieldMenuProps {
3436 onClear ?: ( ) => void ;
3537 itemNameSingular ?: string ; // Defaults to 'field'
3638 showAccessITLink ?: boolean ;
39+ onSearchChange ?: ( searchValue : string ) => void ;
40+ isSearching ?: boolean ;
3741}
3842
3943export const FieldMenu = forwardRef < HTMLDivElement , FieldMenuProps > (
@@ -44,6 +48,8 @@ export const FieldMenu = forwardRef<HTMLDivElement, FieldMenuProps>(
4448 itemNameSingular = 'field' ,
4549 showAccessITLink = true ,
4650 onClear,
51+ onSearchChange,
52+ isSearching = false ,
4753 } ,
4854 ref
4955 ) => {
@@ -80,9 +86,14 @@ export const FieldMenu = forwardRef<HTMLDivElement, FieldMenuProps>(
8086 /* v8 ignore next */
8187 const handleSearchOnChange = ( event : ChangeEvent < HTMLInputElement > ) => {
8288 setSearchValue ( event . target . value ) ;
89+ onSearchChange ?.( event . target . value ) ;
8390 } ;
8491
85- const showSearchInput = availableFields . length >= 4 ;
92+ const showSearchInput =
93+ availableFields . length >= 4 ||
94+ onSearchChange !== undefined ||
95+ isSearching ;
96+
8697 const noSearchResult = filteredFields . length === 0 && showSearchInput ;
8798
8899 if ( ! selectedField && ! onClear ) return null ;
@@ -155,7 +166,7 @@ export const FieldMenu = forwardRef<HTMLDivElement, FieldMenuProps>(
155166 </ div >
156167 </ MenuFixedItem >
157168 ) }
158- { noSearchResult ? (
169+ { noSearchResult && ! isSearching ? (
159170 < NoSearchResultsContainer >
160171 < NoFieldsText
161172 variant = "body_short"
@@ -181,6 +192,11 @@ export const FieldMenu = forwardRef<HTMLDivElement, FieldMenuProps>(
181192 </ MenuItem >
182193 ) )
183194 ) }
195+ { isSearching && (
196+ < MenuItemSkeletonWrapper >
197+ < ListItemSkeleton data-testid = "field-menu-search-skeleton" />
198+ </ MenuItemSkeletonWrapper >
199+ ) }
184200 </ ListContainer >
185201 </ MenuSection >
186202 { showAccessITLink && ! noSearchResult && (
0 commit comments