Navigator: Split NaviagtorContainer from NavigatorProvider#46099
Navigator: Split NaviagtorContainer from NavigatorProvider#46099noisysocks wants to merge 3 commits intotrunkfrom
Navigator: Split NaviagtorContainer from NavigatorProvider#46099Conversation
|
|
|
@ciampo: What do you think of this refactor? Needed so that I can have navigator links for the Styles panel that live outside of the Styles panel in #45960. (You click on the block in the Style Book and it navigates to the block's screen in Styles.) Two alternative approaches I can think of:
Alternative 1 above is kinda tempting. But would splitting |
|
Size Change: +115 B (0%) Total Size: 1.32 MB
ℹ️ View Unchanged
|
| let { children } = contextProps; | ||
|
|
||
| const hasScreenChildren = Children.toArray( children ).some( | ||
| ( child ) => isValidElement( child ) && child.type === NavigatorScreen |
There was a problem hiding this comment.
Hm, actually, this doesn't really work in practice because children are often a component that wraps NavigatorScreen e.g. GlobalStylesNavigatorScreen.
I'm going to go with this approach. That way all of the work can stay in |
|
I never actually wondered if |
What?
Splits a new
NavigatorContainercomponent from the existingNavigatorProvidercomponent. This means thatNavigatorProviderwill provide a context and not render anything.Why?
This allows me to hoist
NavigatorContextup to the root of the site editor and placeNavigatorLinks in places outside of the Styles panel'sNavigatorProvider. See #45960.How?
Moves the non-context logic out of
NavigatorProviderand intoNavigatorContainer. Backwards compatibility is maintained by havingNavigatorProviderwrap its children withNaviagtorContainerif it detects aNavigatorScreenchild.Testing Instructions
Screenshots or screencast