@@ -98,7 +98,10 @@ export function mergeProps(
98
98
return Object . keys ( toolbar ) . filter ( key => key !== 'ariaLabels' ) . length > 0 ? toolbar : null ;
99
99
}
100
100
101
- export function useMultiAppLayout ( props : SharedProps , isEnabled : boolean ) {
101
+ export function useMultiAppLayout (
102
+ props : SharedProps ,
103
+ isEnabled : boolean
104
+ ) : { registered : boolean ; toolbarProps : ToolbarProps | null } {
102
105
const [ registration , setRegistration ] = useState < RegistrationState < SharedProps > | null > ( null ) ;
103
106
const { forceDeduplicationType } = props ;
104
107
const isToolbar = useAppLayoutFlagEnabled ( ) ;
@@ -111,9 +114,13 @@ export function useMultiAppLayout(props: SharedProps, isEnabled: boolean) {
111
114
setRegistration ( { type : 'primary' , discoveredProps : [ ] } ) ;
112
115
return ;
113
116
}
114
- return awsuiPluginsInternal . appLayoutWidget . register ( forceDeduplicationType , props =>
117
+ const unregister = awsuiPluginsInternal . appLayoutWidget . register ( forceDeduplicationType , props =>
115
118
setRegistration ( props as RegistrationState < SharedProps > )
116
119
) ;
120
+ return ( ) => {
121
+ unregister ( ) ;
122
+ setRegistration ( { type : 'suspended' } ) ;
123
+ } ;
117
124
} , [ forceDeduplicationType , isEnabled , isToolbar ] ) ;
118
125
119
126
useLayoutEffect ( ( ) => {
@@ -124,7 +131,7 @@ export function useMultiAppLayout(props: SharedProps, isEnabled: boolean) {
124
131
125
132
if ( ! isToolbar ) {
126
133
return {
127
- registered : 'primary' ,
134
+ registered : true ,
128
135
// mergeProps is needed here because the toolbar's behavior depends on reconciliation logic
129
136
// in this function. For example, navigation trigger visibility
130
137
toolbarProps : mergeProps ( props , [ ] ) ,
0 commit comments