@@ -19,8 +19,8 @@ import {
1919 SEARCH ,
2020 SHOW_FILTER_BAR
2121} from '../../i18n/i18n-defaults.js' ;
22- import type { DialogDomRef , ToolbarButtonDomRef } from '../../webComponents/index.js' ;
23- import { Icon , Toolbar , ToolbarButton } from '../../webComponents/index.js' ;
22+ import type { ButtonDomRef , DialogDomRef , ToolbarButtonDomRef } from '../../webComponents/index.js' ;
23+ import { Button , Icon , Toolbar , ToolbarButton } from '../../webComponents/index.js' ;
2424import { FilterGroupItem } from '../FilterGroupItem/index.js' ;
2525import type { FilterGroupItemInternalProps } from '../FilterGroupItem/types.js' ;
2626import { FlexBox } from '../FlexBox/index.js' ;
@@ -99,7 +99,7 @@ const FilterBar = forwardRef<HTMLDivElement, FilterBarPropTypes>((props, ref) =>
9999 const dialogRef = useRef < DialogDomRef > ( null ) ;
100100 const filterBarButtonsRef = useRef ( null ) ;
101101 const filterAreaRef = useRef < HTMLDivElement > ( null ) ;
102- const filterBtnRef = useRef < ToolbarButtonDomRef > ( null ) ;
102+ const filterBtnRef = useRef < ToolbarButtonDomRef | ButtonDomRef > ( null ) ;
103103
104104 const i18nBundle = useI18nBundle ( '@ui5/webcomponents-react' ) ;
105105 const uniqueId = useId ( ) ;
@@ -217,9 +217,21 @@ const FilterBar = forwardRef<HTMLDivElement, FilterBarPropTypes>((props, ref) =>
217217
218218 const cssClasses = clsx ( classNames . outerContainer , className , ! hideToolbar && classNames . outerContainerWithToolbar ) ;
219219
220- const ToolbarButtons = (
220+ const FBButtonComponent = hideToolbar ? Button : ToolbarButton ;
221+ const filtersButtonText = `${ filtersText } ${
222+ activeFiltersCount && parseInt ( activeFiltersCount as string , 10 ) ? ` (${ activeFiltersCount } )` : ''
223+ } `;
224+ const FBButtons = (
221225 < >
222- { showGoOnFB && < ToolbarButton text = { goText } onClick = { handleGoOnFb } design = { ButtonDesign . Emphasized } /> }
226+ { showGoOnFB && (
227+ < FBButtonComponent
228+ text = { hideToolbar ? undefined : goText }
229+ onClick = { handleGoOnFb }
230+ design = { ButtonDesign . Emphasized }
231+ >
232+ { hideToolbar ? goText : undefined }
233+ </ FBButtonComponent >
234+ ) }
223235 { ! hideToggleFiltersButton && ! hideToolbar && ! isPhone && (
224236 < ToolbarButton
225237 text = { showFilters ? hideFilterBarText : showFilterBarText }
@@ -229,20 +241,35 @@ const FilterBar = forwardRef<HTMLDivElement, FilterBarPropTypes>((props, ref) =>
229241 aria-live = "polite"
230242 />
231243 ) }
232- { showClearOnFB && < ToolbarButton text = { clearText } onClick = { handleClear } design = { ButtonDesign . Transparent } /> }
244+ { showClearOnFB && (
245+ < FBButtonComponent
246+ text = { hideToolbar ? undefined : clearText }
247+ onClick = { handleClear }
248+ design = { ButtonDesign . Transparent }
249+ >
250+ { hideToolbar ? clearText : undefined }
251+ </ FBButtonComponent >
252+ ) }
233253 { showRestoreOnFB && (
234- < ToolbarButton text = { restoreText } onClick = { handleFBRestore } design = { ButtonDesign . Transparent } />
254+ < FBButtonComponent
255+ text = { hideToolbar ? undefined : restoreText }
256+ onClick = { handleFBRestore }
257+ design = { ButtonDesign . Transparent }
258+ >
259+ { hideToolbar ? restoreText : undefined }
260+ </ FBButtonComponent >
235261 ) }
236262 { ! hideFilterConfiguration && (
237- < ToolbarButton
238- text = { `${ filtersText } ${
239- activeFiltersCount && parseInt ( activeFiltersCount as string , 10 ) > 0 ? ` (${ activeFiltersCount } )` : ''
240- } `}
263+ < FBButtonComponent
264+ text = { hideToolbar ? undefined : filtersButtonText }
241265 onClick = { handleDialogOpen }
242266 aria-haspopup = "dialog"
243267 design = { ButtonDesign . Transparent }
268+ //@ts -expect-error: both types are allowed here
244269 ref = { filterBtnRef }
245- />
270+ >
271+ { hideToolbar ? filtersButtonText : undefined }
272+ </ FBButtonComponent >
246273 ) }
247274 </ >
248275 ) ;
@@ -338,7 +365,7 @@ const FilterBar = forwardRef<HTMLDivElement, FilterBarPropTypes>((props, ref) =>
338365 < FlexBox className = { classNames . toolbar } alignItems = { FlexBoxAlignItems . Center } >
339366 { header }
340367 < Toolbar className = { classNames . wcToolbar } design = { ToolbarDesign . Transparent } >
341- { ToolbarButtons }
368+ { FBButtons }
342369 </ Toolbar >
343370 </ FlexBox >
344371 ) }
@@ -373,7 +400,7 @@ const FilterBar = forwardRef<HTMLDivElement, FilterBarPropTypes>((props, ref) =>
373400 className = { classNames . lastSpacer }
374401 >
375402 < div className = { classNames . filterBarButtons } ref = { filterBarButtonsRef } >
376- { ToolbarButtons }
403+ { FBButtons }
377404 </ div >
378405 </ div >
379406 </ >
0 commit comments