@@ -18,6 +18,7 @@ import {
1818 getAppbarBackgroundColor ,
1919 modeAppbarHeight ,
2020 renderAppbarContent ,
21+ filterAppbarActions ,
2122} from './utils' ;
2223import { useInternalTheme } from '../../core/theming' ;
2324import type { MD3Elevation , ThemeProp } from '../../types' ;
@@ -228,15 +229,6 @@ const Appbar = ({
228229 shouldAddRightSpacing = shouldCenterContent && rightItemsCount === 0 ;
229230 }
230231
231- const filterAppbarActions = React . useCallback (
232- ( isLeading = false ) =>
233- React . Children . toArray ( children ) . filter ( ( child ) =>
234- // @ts -expect-error: TypeScript complains about the type of type but it doesn't matter
235- isLeading ? child . props . isLeading : ! child . props . isLeading
236- ) ,
237- [ children ]
238- ) ;
239-
240232 const spacingStyle = isV3 ? styles . v3Spacing : styles . spacing ;
241233
242234 const insets = {
@@ -264,7 +256,11 @@ const Appbar = ({
264256 { shouldAddLeftSpacing ? < View style = { spacingStyle } /> : null }
265257 { ( ! isV3 || isMode ( 'small' ) || isMode ( 'center-aligned' ) ) &&
266258 renderAppbarContent ( {
267- children,
259+ children : [
260+ // Filter appbar actions - first leading icons, then trailing icons
261+ ...filterAppbarActions ( children , true ) ,
262+ ...filterAppbarActions ( children ) ,
263+ ] ,
268264 isDark,
269265 theme,
270266 isV3,
@@ -288,7 +284,7 @@ const Appbar = ({
288284 mode,
289285 } ) }
290286 { renderAppbarContent ( {
291- children : filterAppbarActions ( true ) ,
287+ children : filterAppbarActions ( children , true ) ,
292288 isDark,
293289 isV3,
294290 renderOnly : [ 'Appbar.Action' ] ,
@@ -297,7 +293,7 @@ const Appbar = ({
297293 { /* Right side of row container, can contain other AppbarAction if they are not leading icons */ }
298294 < View style = { styles . rightActionControls } >
299295 { renderAppbarContent ( {
300- children : filterAppbarActions ( false ) ,
296+ children : filterAppbarActions ( children ) ,
301297 isDark,
302298 isV3,
303299 renderExcept : [
@@ -310,7 +306,6 @@ const Appbar = ({
310306 } ) }
311307 </ View >
312308 </ View >
313- { /* Middle of the row, can contain only AppbarContent */ }
314309 { renderAppbarContent ( {
315310 children,
316311 isDark,
0 commit comments