-
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
remove nested toasters #2153
Merged
Merged
remove nested toasters #2153
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
826cadf
remove nested toasters
mayank99 ddcd2f7
fix `portalContainerProp`
mayank99 a493546
typo
mayank99 5a6321f
Merge branch 'main' into mayank/remove-redundant-toasters
mayank99 14366e3
create Toaster when using explicit prop
mayank99 0d31173
test
mayank99 9c3aedb
changeset
mayank99 0632775
remove `initialFocus` from `Popover`
mayank99 5a6efbd
update images
mayank99 824b9e4
changeset
mayank99 48a5b64
Merge branch 'mayank/popover-initial-focus' into mayank/remove-redund…
mayank99 acd5792
update images
mayank99 2ea3285
Merge branch 'main' into mayank/popover-initial-focus
mayank99 530762c
tests
mayank99 f521308
Merge branch 'mayank/popover-initial-focus' into mayank/remove-redund…
mayank99 85ba7e3
update TimePicker images?
mayank99 f1ecb1b
remove unused import
mayank99 e88ae10
add combined test for `focusInput` and `imperativeFocus`
mayank99 dfa5491
Merge branch 'main' into mayank/popover-initial-focus
mayank99 11c08f1
Merge branch 'main' into mayank/popover-initial-focus
mayank99 336141b
fix test
mayank99 28daf1e
Merge branch 'mayank/popover-initial-focus' into mayank/remove-redund…
mayank99 f2b2598
update failing test image (again)
mayank99 e025d48
update changeset
mayank99 61aecb6
Merge branch 'mayank/popover-initial-focus' into mayank/remove-redund…
mayank99 34267f7
Merge branch 'main' into mayank/remove-redundant-toasters
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@itwin/itwinui-react': minor | ||
--- | ||
|
||
Nested `ThemeProvider`s will now reuse the same toaster instead of creating new ones. | ||
Binary file modified
BIN
-141 Bytes
(99%)
...react-workshop/cypress-visual-screenshots/baseline/DatePicker.test.ts-Basic.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-160 Bytes
(99%)
...t-workshop/cypress-visual-screenshots/baseline/DatePicker.test.ts-Localized.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-166 Bytes
(99%)
...p/cypress-visual-screenshots/baseline/DatePicker.test.ts-With Combined Time.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-97 Bytes
(100%)
...t-workshop/cypress-visual-screenshots/baseline/DatePicker.test.ts-With Time.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-124 Bytes
(100%)
...t-workshop/cypress-visual-screenshots/baseline/DatePicker.test.ts-With Year.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-201 Bytes
(100%)
...ct-workshop/cypress-visual-screenshots/baseline/Table.test.ts-Custom Filter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-54 Bytes
(100%)
apps/react-workshop/cypress-visual-screenshots/baseline/Table.test.ts-Filters.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-39 Bytes
(100%)
.../react-workshop/cypress-visual-screenshots/baseline/Table.test.ts-Localized.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+573 Bytes
(100%)
...hop/cypress-visual-screenshots/baseline/TimePicker.test.ts-Custom Renderers.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import * as React from 'react'; | ||
import { useSearchParams } from '@remix-run/react'; | ||
import { ThemeProvider, useToaster } from '@itwin/itwinui-react'; | ||
|
||
export default function Page() { | ||
const [searchParams] = useSearchParams(); | ||
const shouldPortal = searchParams.get('portal') === 'true'; | ||
const isClient = useIsClient(); | ||
|
||
return ( | ||
<> | ||
<Toast text='Toast (root)' /> | ||
|
||
<ThemeProvider data-container='nested'> | ||
<Toast text='Toast (nested)' /> | ||
</ThemeProvider> | ||
|
||
{isClient && shouldPortal && ( | ||
<ThemeProvider portalContainer={document.body}> | ||
<Toast text='Toast (portal)' /> | ||
</ThemeProvider> | ||
)} | ||
</> | ||
); | ||
} | ||
|
||
function Toast({ text = 'Toast' }) { | ||
const toaster = useToaster(); | ||
|
||
React.useEffect(() => { | ||
toaster.informational(text, { type: 'persisting' }); | ||
}, [toaster]); | ||
|
||
return null; | ||
} | ||
|
||
function useIsClient() { | ||
const [isClient, setIsClient] = React.useState(false); | ||
|
||
React.useEffect(() => { | ||
setIsClient(true); | ||
}, []); | ||
|
||
return isClient; | ||
} |
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,24 @@ | ||
import { test, expect } from '@playwright/test'; | ||
|
||
test.describe('Toaster', () => { | ||
test('should not create nested toast containers', async ({ page }) => { | ||
await page.goto('/Toaster'); | ||
|
||
const rootToast = page.getByText('Toast (root)'); | ||
await expect(rootToast).toBeVisible(); | ||
|
||
const nestedToast = page.getByText('Toast (nested)'); | ||
await expect(nestedToast).toBeVisible(); | ||
|
||
await expect(page.locator('[data-container="nested"]')).not.toContainText( | ||
'Toast', | ||
); | ||
}); | ||
|
||
test('should work when using portalContainer prop', async ({ page }) => { | ||
await page.goto('/Toaster?portal=true'); | ||
|
||
const portalToast = page.getByText('Toast (portal)'); | ||
await expect(portalToast).toBeVisible(); | ||
}); | ||
}); |
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.
Should this be "toast wrapper" instead of "toaster"?
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 used "toaster" because that's the terminology that our users are more familiar with, and because it's also more accurate, since we are now actually using the same reducer (rather than just the same DOM element).