-
Notifications
You must be signed in to change notification settings - Fork 38
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
re-add shadow DOM styles when reparented #2252
Merged
Merged
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
116a914
re-add shadow DOM styles when reparented
mayank99 b5ee135
add test for popout
mayank99 ef0fb8d
fix main reparent issue
mayank99 3b169b7
Merge branch 'main' into mayank/fix-reparent-styles
mayank99 2b5e2fd
use `render` instead of `portal` to test first mount
mayank99 7c1ea77
fix one-time CSS addition
mayank99 2052989
use same order as before
mayank99 9c61f36
comment
mayank99 6a03921
changeset
mayank99 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
Oops, something went wrong.
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.
@GerardasB What do you think would be the best way to test this? It would be difficult to add a proper test for this in iTwinUI without manually recreating the custom event / reparenting logic.
I'm thinking we first manually verify that it works within the AppUI repo (by editing
@itwin/itwinui-react
innode_modules
) and then after this is released, we can update the existing AppUI test scenario to ensure the styles look fine without any special handling on top ofProgressRadial
.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.
Sounds good, I'll verify if this change works and let you know.
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 can confirm, this works correctly in the reparenting use-case (I made sure to remove the custom
useEffect
workaround https://github.com/iTwin/appui/blob/b1c1d0c95a58ebbf2985bb2e61ad01d639e7f795/apps/test-app/src/frontend/appui/frontstages/TestPopoutFrontstage.tsx#L90)However, this change breaks the regular use-case, where no reparenting is done and the component is simply mounted in a new window. (
reparentPopoutWidgets=0
to configure in AppUI test-app: https://github.com/iTwin/appui/blob/b1c1d0c95a58ebbf2985bb2e61ad01d639e7f795/e2e-tests/tests/popout-widget.test.ts#L210)This happens because
useEffect
that is scheduled inuseLatestRef(shadowRoot)
runs after thecreateStyleSheet
called afterReactDOM4.flushSync()
, which results increateStyleSheet
returning early due tonull
latestShadowRoot.current
.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 testing it. I believe I've fixed the regular popout case in my latest changes. I'm passing the already existing
shadow
intocreateStyleSheet
(rather than relying onuseLatestRef
).I also added a basic test for it, since this test does not require us to reimplement any reparenting logic.
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.
Looks good now!