-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Block Controls SlotFill: refactor to allow passing multiple contexts, including internal components context #51264
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
86f704b
SlotFill: pass array of contexts in fillProps, use it to pass compone…
jsnajdr 713c6db
Use lock/unlock instead of exporting experimental API
ciampo 17abb77
Pass props object instead of just value prop
jsnajdr d3d28b2
Mobile BlockControlsSlot: remove ToolbarContext teleport, the context…
jsnajdr 98ad917
Put forwardedContext into a fillProps field
jsnajdr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also cc'ing @dcalhoun and @fluiddot since this PR touches native files, although the code changes are just a refactor of how data is passed to the
Slot
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we also use the components context system in React Native code? Because I added the provider teleporting only to the web
BlockControlsSlot
, not to the mobile one.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also it seems that in React Native we don't support the
bubblesVirtually
variant with portals. ThebubblesVirtually
prop is simply ignored. The Fill is always rendered in the Slot's React tree. It doesn't see context from the Fill tree, and teleporting the toolbar context is not needed, the component already sees it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Folks from the mobile team may be best suited to answer here.
From a quick look, I don't think that there are native components explicitly using the components context system, although it is my understanding that web versions of components could be used by React Native, meaning that we'll likely neet to pass all the context values that we do in the web counterpart?
If that's the case, though, then forwarding such contexts is not necessary, as you say.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I pushed a commit that removes context forwarding (teleporting) from the
slot.native.js
component completely, including the pre-exisitingToolbarContext
. Mobile uses the non-virtual Slot implementation, and all these contexts (toolbar, component system, Emotion styles) are already present it its parent React tree.We'll need to reintroduce the forwarding when we migrate mobile slotfills to the portal
bubblesVirtually
implementation.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the call out @ciampo 🙇 ! As you shared in the above comments, the
SlotFill
implementation in React Native is limited compared to the web version as we don't supportbubblesVirtually
. I checked the usage ofToolbarContext
and seems we are not using it, only in the web version, so I agree on removing it from here.Web:
gutenberg/packages/components/src/toolbar/toolbar/toolbar-container.tsx
Line 35 in e892b05
Native:
gutenberg/packages/components/src/toolbar/toolbar/toolbar-container.native.js
Line 6 in e892b05
Regarding these changes, I tested locally and I encountered an error that I shared here. Let me know if I can help anyhow, thanks!