-
-
Notifications
You must be signed in to change notification settings - Fork 294
Allow overriding "reason" in closeSnackbar #620
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -279,11 +279,11 @@ export interface SharedProps<V extends VariantType = VariantType> extends Partia | |
| * @param {object} event The event source of the callback | ||
| * @param {string} reason Can be:`"timeout"` (`autoHideDuration` expired) or: `"maxsnack"` | ||
| * (snackbar was closed because `maxSnack` has reached) or: `"instructed"` (snackbar was | ||
| * closed programmatically) | ||
| * closed programmatically) or: any string if closeSnackbar had reason parameter | ||
| * @param {string|number|undefined} key key of a Snackbar. key will be `undefined` if closeSnackbar | ||
| * is called with no key (user requested all the snackbars to be closed) | ||
| */ | ||
| onClose?: (event: React.SyntheticEvent<any> | null, reason: CloseReason, key?: SnackbarKey) => void; | ||
| onClose?: (event: React.SyntheticEvent<any> | null, reason: CloseReason | string, key?: SnackbarKey) => void; | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The reason I didn't edit the Workaround would be to change the type to |
||
| } | ||
|
|
||
| /** | ||
|
|
@@ -405,7 +405,7 @@ interface EnqueueSnackbar { | |
|
|
||
| export interface ProviderContext { | ||
| enqueueSnackbar: EnqueueSnackbar; | ||
| closeSnackbar: (key?: SnackbarKey) => void; | ||
| closeSnackbar: (key?: SnackbarKey, reason?: string) => void; | ||
| } | ||
|
|
||
| export declare class SnackbarProvider extends React.Component<SnackbarProviderProps> { | ||
|
|
||

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.
Reason has been set by default to 'instructed' to avoid any possible issues with migrating to next version.
this PR should be a minor change given that existing implementation don't change in behavior