-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
re-add shadow DOM styles when reparented (#2252)
- Loading branch information
Showing
4 changed files
with
97 additions
and
13 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@itwin/itwinui-react': patch | ||
--- | ||
|
||
Fixed an issue where some components (e.g. `VisuallyHidden` inside `ProgressRadial`) were losing their styles when reparented into a different window. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import * as React from 'react'; | ||
import * as ReactDOM from 'react-dom'; | ||
import { VisuallyHidden, ThemeProvider } from '@itwin/itwinui-react'; | ||
import { useSearchParams } from '@remix-run/react'; | ||
|
||
export default function Page() { | ||
const [searchParams] = useSearchParams(); | ||
|
||
if (searchParams.get('popout') === 'true') { | ||
return <PopoutTest />; | ||
} | ||
|
||
return null; | ||
} | ||
|
||
/** https://github.com/iTwin/iTwinUI/pull/2252#discussion_r1766676900 */ | ||
function PopoutTest() { | ||
const popout = usePopout(); | ||
|
||
return ( | ||
<> | ||
<button onClick={popout.open}>Open popout</button> | ||
{popout.popout && | ||
ReactDOM.render( | ||
<ThemeProvider> | ||
<VisuallyHidden>Hello</VisuallyHidden> | ||
</ThemeProvider>, | ||
popout.popout.document.body, | ||
)} | ||
</> | ||
); | ||
} | ||
|
||
// ---------------------------------------------------------------------------- | ||
|
||
function usePopout() { | ||
const [popout, setPopout] = React.useState<Window | null>(null); | ||
|
||
const open = React.useCallback(() => { | ||
const popout = window.open('', 'popout', 'width=400,height=400'); | ||
setPopout(popout); | ||
}, []); | ||
|
||
return React.useMemo(() => ({ open, popout }), [open, popout]); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { test, expect } from '@playwright/test'; | ||
|
||
test('styles should exist in popout window', async ({ page }) => { | ||
const popoutPromise = page.waitForEvent('popup'); | ||
await page.goto('/VisuallyHidden?popout=true'); | ||
await page.click('button'); | ||
const popout = await popoutPromise; | ||
|
||
const visuallyHidden = popout.getByText('Hello'); | ||
await expect(visuallyHidden).toHaveCSS('position', 'absolute'); | ||
}); |