Reusable Fluent UI v9 Toast control for SPFx solutions - #2131
Open
HarminderSethi wants to merge 1 commit into
Open
Reusable Fluent UI v9 Toast control for SPFx solutions#2131HarminderSethi wants to merge 1 commit into
HarminderSethi wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
There is a confirmed timeout default bug when durationUnit="seconds" is set without duration, and the Controls Test toggle list is missing controls that are rendered/typed, preventing them from being enabled individually.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR introduces a reusable Fluent UI v9 Toast control for SPFx consumers, aiming to provide a zero-configuration declarative <Toast /> experience plus a shared ToastProvider/useToast() API, and wires it into the Controls Test harness and documentation.
Changes:
- Added new Toast control implementation (
Toast,ToastProvider,useToast) with Fluent UI v9 Toaster integration. - Exported the control through the public package surface (
src/Toast.ts,src/index.ts). - Added Controls Test + documentation integration (visibility toggles, manifest defaults, mkdocs nav, new Toast docs page).
File summaries
| File | Description |
|---|---|
| src/webparts/controlsTest/propertyPane/controls/ControlToggles.tsx | Adds Toast to the property-pane control toggles list (and should include other missing toggles). |
| src/webparts/controlsTest/IControlsTestWebPartProps.ts | Extends ValidControls union to include Toast. |
| src/webparts/controlsTest/ControlsTestWebPart.manifest.json | Adds Toast default visibility flag. |
| src/webparts/controlsTest/components/ControlsTest.tsx | Lazy-loads and renders a sample Toast section in Controls Test. |
| src/Toast.ts | Public entrypoint re-export for the toast control bundle. |
| src/index.ts | Exposes Toast from the main library index. |
| src/controls/toast/useToast.ts | Adds useToast() hook for imperative dispatch via a shared provider. |
| src/controls/toast/ToastProvider.tsx | Implements provider/controller wiring, dispatch logic, and timeout calculation. |
| src/controls/toast/Toast.tsx | Implements declarative <Toast /> that dispatches on mount and auto-wraps in a provider when needed. |
| src/controls/toast/IToast.ts | Defines Toast props/options/provider/controller public types. |
| src/controls/toast/index.ts | Barrel exports and Fluent UI re-exports for toast-related primitives/types. |
| docs/documentation/mkdocs.yml | Adds Toast page to mkdocs navigation. |
| docs/documentation/docs/index.md | Lists Toast in the documentation index. |
| docs/documentation/docs/controls/Toast.md | Adds end-user documentation for Toast/ToastProvider/useToast usage and API surface. |
Review details
- Files reviewed: 14/14 changed files
- Comments generated: 3
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+44
to
+45
| const duration = options.duration ?? DEFAULT_DURATION_MS; | ||
| return options.durationUnit === 'seconds' ? duration * 1000 : duration; |
Comment on lines
69
to
72
| "TaxonomyPicker", "TaxonomyTree", "Teams", "TermSetNavigation", | ||
| "TestControl", "Toolbar", "TreeView", | ||
| "TestControl", "Toolbar", "Toast", "TreeView", | ||
| "UploadFiles", "UserPicker", "VariantThemeProvider", | ||
| "ViewPicker", "WebPartTitle", "Calendar" |
Comment on lines
+39
to
+46
| const getTimeout = (options: IShowToastOptions): number => { | ||
| if (!options.autoDismiss) { | ||
| return -1; | ||
| } | ||
|
|
||
| const duration = options.duration ?? DEFAULT_DURATION_MS; | ||
| return options.durationUnit === 'seconds' ? duration * 1000 : duration; | ||
| }; |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What's in this Pull Request?
A reusable Fluent UI v9 Toast control for SPFx solutions. It removes the need for consumers to manually configure FluentProvider, Toaster, controller IDs, dispatch logic, and notification lifecycle behavior.
Features
Zero-configuration declarative
Shared ToastProvider and useToast() API
Native queueing, stacking, limits, and positioning
Intent icons and accessible live-region behavior
Auto-dismiss, pause, resume, and manual dismissal
Custom themes, content, actions, styles, and portal targets
Controls Test integration and documentation