Skip to content

Commit

Permalink
[docs-app] Fix minor bug in upload toast example (#3626)
Browse files Browse the repository at this point in the history
  • Loading branch information
adidahiya authored Jun 26, 2019
1 parent bde7430 commit 1a6c67c
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/docs-app/src/examples/core-examples/toastExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ export class ToastExample extends React.PureComponent<IExampleProps<IBlueprintEx
private refHandlers = {
toaster: (ref: Toaster) => (this.toaster = ref),
};
private progressToastInterval?: number;

private handlePositionChange = handleStringChange((position: ToasterPosition) => this.setState({ position }));
private toggleAutoFocus = handleBooleanChange(autoFocus => this.setState({ autoFocus }));
Expand Down Expand Up @@ -157,6 +158,12 @@ export class ToastExample extends React.PureComponent<IExampleProps<IBlueprintEx
value={amount / 100}
/>
),
onDismiss: (didTimeoutExpire: boolean) => {
if (!didTimeoutExpire) {
// user dismissed toast with click
window.clearInterval(this.progressToastInterval);
}
},
timeout: amount < 100 ? 0 : 2000,
};
}
Expand All @@ -170,9 +177,9 @@ export class ToastExample extends React.PureComponent<IExampleProps<IBlueprintEx
private handleProgressToast = () => {
let progress = 0;
const key = this.toaster.show(this.renderProgress(0));
const interval = setInterval(() => {
this.progressToastInterval = window.setInterval(() => {
if (this.toaster == null || progress > 100) {
clearInterval(interval);
window.clearInterval(this.progressToastInterval);
} else {
progress += 10 + Math.random() * 20;
this.toaster.show(this.renderProgress(progress), key);
Expand Down

1 comment on commit 1a6c67c

@blueprint-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[docs-app] Fix minor bug in upload toast example (#3626)

Previews: documentation | landing | table

Please sign in to comment.