-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(toast): proper handling of
autohide
toggling (#3283)
Toasts initially setup with `[autohide]="true"`were wrongly still emitting `(hide)` output after toggling `autohide` to `false`. A new demo has also been created to illustrate the `autohide` toggling support, 'Prevent autohide on mouseover'. Fixes #3280
- Loading branch information
Benoit Charbonnier
committed
Jul 15, 2019
1 parent
cc29290
commit ffcdad4
Showing
6 changed files
with
87 additions
and
10 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
demo/src/app/components/toast/demos/prevent-autohide/toast-prevent-autohide.html
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 @@ | ||
<p> | ||
In this demo, you can show a toast by clicking the button below. It will hide itself after a 5 seconds delay unless you simply hover it with your mouse. | ||
</p> | ||
<button class="btn btn-primary" (click)="show = true"> | ||
Click me to show a toast | ||
</button> | ||
<hr *ngIf="show"> | ||
<ngb-toast | ||
*ngIf="show" | ||
header="Autohide can be cancelled" | ||
[delay]="5000" | ||
[autohide]="autohide" | ||
(mouseenter)="autohide = false" | ||
(mouseleave)="autohide = true" | ||
(hide)="show = false; autohide = true" | ||
[class.bg-warning]="!autohide" | ||
> | ||
<div *ngIf="autohide"> | ||
Try to mouse hover me. | ||
</div> | ||
<div *ngIf="!autohide"> | ||
I will remain visible until you leave again. | ||
</div> | ||
</ngb-toast> |
13 changes: 13 additions & 0 deletions
13
demo/src/app/components/toast/demos/prevent-autohide/toast-prevent-autohide.module.ts
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,13 @@ | ||
import {NgModule} from '@angular/core'; | ||
import {BrowserModule} from '@angular/platform-browser'; | ||
import {NgbModule} from '@ng-bootstrap/ng-bootstrap'; | ||
|
||
import {NgbdToastPreventAutohide} from './toast-prevent-autohide'; | ||
|
||
@NgModule({ | ||
imports: [BrowserModule, NgbModule], | ||
declarations: [NgbdToastPreventAutohide], | ||
bootstrap: [NgbdToastPreventAutohide] | ||
}) | ||
export class NgbdToastPreventAutohideModule { | ||
} |
8 changes: 8 additions & 0 deletions
8
demo/src/app/components/toast/demos/prevent-autohide/toast-prevent-autohide.ts
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,8 @@ | ||
import {Component} from '@angular/core'; | ||
|
||
@Component({selector: 'ngbd-toast-prevent-autohide', templateUrl: './toast-prevent-autohide.html'}) | ||
|
||
export class NgbdToastPreventAutohide { | ||
show = false; | ||
autohide = true; | ||
} |
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