@@ -19,8 +19,8 @@ import {
19
19
SEARCH ,
20
20
SHOW_FILTER_BAR
21
21
} 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' ;
24
24
import { FilterGroupItem } from '../FilterGroupItem/index.js' ;
25
25
import type { FilterGroupItemInternalProps } from '../FilterGroupItem/types.js' ;
26
26
import { FlexBox } from '../FlexBox/index.js' ;
@@ -99,7 +99,7 @@ const FilterBar = forwardRef<HTMLDivElement, FilterBarPropTypes>((props, ref) =>
99
99
const dialogRef = useRef < DialogDomRef > ( null ) ;
100
100
const filterBarButtonsRef = useRef ( null ) ;
101
101
const filterAreaRef = useRef < HTMLDivElement > ( null ) ;
102
- const filterBtnRef = useRef < ToolbarButtonDomRef > ( null ) ;
102
+ const filterBtnRef = useRef < ToolbarButtonDomRef | ButtonDomRef > ( null ) ;
103
103
104
104
const i18nBundle = useI18nBundle ( '@ui5/webcomponents-react' ) ;
105
105
const uniqueId = useId ( ) ;
@@ -217,9 +217,21 @@ const FilterBar = forwardRef<HTMLDivElement, FilterBarPropTypes>((props, ref) =>
217
217
218
218
const cssClasses = clsx ( classNames . outerContainer , className , ! hideToolbar && classNames . outerContainerWithToolbar ) ;
219
219
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 = (
221
225
< >
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
+ ) }
223
235
{ ! hideToggleFiltersButton && ! hideToolbar && ! isPhone && (
224
236
< ToolbarButton
225
237
text = { showFilters ? hideFilterBarText : showFilterBarText }
@@ -229,20 +241,35 @@ const FilterBar = forwardRef<HTMLDivElement, FilterBarPropTypes>((props, ref) =>
229
241
aria-live = "polite"
230
242
/>
231
243
) }
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
+ ) }
233
253
{ 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 >
235
261
) }
236
262
{ ! hideFilterConfiguration && (
237
- < ToolbarButton
238
- text = { `${ filtersText } ${
239
- activeFiltersCount && parseInt ( activeFiltersCount as string , 10 ) > 0 ? ` (${ activeFiltersCount } )` : ''
240
- } `}
263
+ < FBButtonComponent
264
+ text = { hideToolbar ? undefined : filtersButtonText }
241
265
onClick = { handleDialogOpen }
242
266
aria-haspopup = "dialog"
243
267
design = { ButtonDesign . Transparent }
268
+ //@ts -expect-error: both types are allowed here
244
269
ref = { filterBtnRef }
245
- />
270
+ >
271
+ { hideToolbar ? filtersButtonText : undefined }
272
+ </ FBButtonComponent >
246
273
) }
247
274
</ >
248
275
) ;
@@ -338,7 +365,7 @@ const FilterBar = forwardRef<HTMLDivElement, FilterBarPropTypes>((props, ref) =>
338
365
< FlexBox className = { classNames . toolbar } alignItems = { FlexBoxAlignItems . Center } >
339
366
{ header }
340
367
< Toolbar className = { classNames . wcToolbar } design = { ToolbarDesign . Transparent } >
341
- { ToolbarButtons }
368
+ { FBButtons }
342
369
</ Toolbar >
343
370
</ FlexBox >
344
371
) }
@@ -373,7 +400,7 @@ const FilterBar = forwardRef<HTMLDivElement, FilterBarPropTypes>((props, ref) =>
373
400
className = { classNames . lastSpacer }
374
401
>
375
402
< div className = { classNames . filterBarButtons } ref = { filterBarButtonsRef } >
376
- { ToolbarButtons }
403
+ { FBButtons }
377
404
</ div >
378
405
</ div >
379
406
</ >
0 commit comments