-
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
Components: Fix Slot
/Fill
Emotion StyleProvider
#38237
Merged
+86
−47
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
f6a5d1d
Fix Slot/Fill emotion style provider
ciampo 2146940
Add slotfill storybook example to `useCx`
ciampo ceb99bb
Use iframe from `@wordpress/block-editor`, add `bubblesVirtually` prop
ciampo caac47f
Fix slotfill name
ciampo e15e9de
Add simpler slotfill example
ciampo 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
Add slotfill storybook example to
useCx
- Loading branch information
commit 2146940b64554d0ecb370a5fe284bb46c19cba9a
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
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.
can you try
bubblesVirtually
prop here?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.
Tried, but it doesn't seem to make a difference
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.
My fix for sure is specific to "bubblesVirtually" implementation which is the one we prefer in Gutenberg in general. (the other is more "historic"). I don't know why it's not working though in storybook, the blue text is the exact same use case as spinner it seems 🤔
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.
This is slightly different though as in the story we've wrapped the
Slot
in a StyleProvider as well. Are we doing that in usage in Gutenberg?This is why I was confused because I was actually able to solve the problem with the
<StyleProvider><Slot /></StyleProvider>
with the context based code that @ciampo and I came up with that I shared here: #37551 (comment)But it didn't work to fix the spinner.
Which makes me thing that this story, as constructed currently, while it raises an edge case that we need to cover, is actually a red herring when compared to the spinner case (and probably the preview iframe issue you were having before @youknowriad).
In short: I don't believe we've been able to actually reproduce the issue that was being found in Gutenberg in the story yet.
If I'm understanding the fix for the GB issue correctly, the minimal reproduction would just be:
And indeed, that is what appears to happen in Gutenberg. But in the story, when you try this, it worked perfectly fine.
It's just occurred to me that potentially it could be because the story is running in an iframe? I didn't get around to trying that minimal reproduction story popped out into it's own document so maybe that would make it possible to reproduce (though should theoretically not matter if we consider that any iframe can just be the "root" document of the page, it doesn't have to be the root document of the window).
Who knows!
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 think I managed to work out a Storybook example which breaks before this fix, and works after this fix.
In an effort to replicate as closely as possible the issue that we're trying to reproduce:
IFrame
component with theIframe
component from@wordpress/block-editor
bubblesVirtually
to both<Slot>
sbubblesVirtually
bubblesVirtually
A couple more notes:
iframe
component seems to be what "allowed the example to be broken"bubblesVirtually
allowed theslot
to receive the fix from this PRI guess an interesting thing would be to understand what was the difference between the two
IFrame
components?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 managed to get around the
IFrame
loading with a bit of a hacky approach as nothing else seemed to work me, but the problem seems to be related to the contents ofcreatePortal
not being rendered (or maybe simply "seen"?) by Jest / RTL.These are the changes that I made so far (I've also added some "debugging" spans to the
Iframe
component to help with troubleshooting):Click to see diff
If anyone has the time to take a look as well it'd be great! Otherwise I plan on spending a little bit more time on it tomorrow.
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.
Just checking if you tried the suggestion in this issue? testing-library/react-testing-library#62
I never really ran into any problems testing portals as far as I can remember but I might have just gotten lucky and avoided testing them directly so far!
Seems like the trick is to pass an extra
container: document.body
argument torender
.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.
Unfortunately adding
{ container: document.body }
as an additional argument torender
triggers a warning, and therenderIntoDocument
method (also mentioned in that issue) is deprecated.I've tried to get inspiration from this example but as soon as the portal doesn't render in the
iframeDocument.documentElement
, more errors appear (for example,ownerNode
here becomesundefined
).Since I've almost spent 2 days on this without managing to get a working unit test, I'm going to merge this PR as-is in order to unblock #37551
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.
Did you manage to have a look at this at all? If not, I can try to also look into it later today / on Monday.
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 was away from my computer yesterday so I didn't get to, but if I have time to look into it today I will!