Skip to content

Commit 0921a1b

Browse files
authored
Merge pull request #8775 from IgniteUI/dTsvetkov/fix-8207-master
fix(toast): isVisible property binding - master
2 parents 2b56923 + 0dea207 commit 0921a1b

File tree

12 files changed

+120
-89
lines changed

12 files changed

+120
-89
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ All notable changes for each version of this project will be documented in this
1515
- Added new property `alignment` that determines the radio group alignment. Available options are `horizontal` (default) and `vertical`.
1616
- `IgxDialog`
1717
- Added new `onOpened` and `onClosed` events.
18+
- `IgxToast`
19+
- **Breaking Change** -
20+
`show` and `hide` methods have been deprecated. `open` and `close` should be used instead.
21+
`onShowing`,`onShown`,`onHiding` and `onHiden` events have been deprecated. `onOpening`, `onOpened`, `onClosing` and `onClosed`should be used instead.
1822
- `IgxInputGroup`
1923
- Added new property `theme` that allows you to set the theme explicitly and at runtime.
2024

projects/igniteui-angular/src/lib/buttonGroup/buttonGroup.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ export class IgxButtonGroupComponent extends DisplayDensityBase implements After
216216
* @ViewChild("toast")
217217
* private toast: IgxToastComponent;
218218
* public onSelect(buttongroup){
219-
* this.toast.show()
219+
* this.toast.open()
220220
* }
221221
* //...
222222
* ```
@@ -233,7 +233,7 @@ export class IgxButtonGroupComponent extends DisplayDensityBase implements After
233233
* @ViewChild("toast")
234234
* private toast: IgxToastComponent;
235235
* public onUnselect(buttongroup){
236-
* this.toast.show()
236+
* this.toast.open()
237237
* }
238238
* //...
239239
* ```

projects/igniteui-angular/src/lib/directives/toggle/toggle.directive.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -219,17 +219,15 @@ export class IgxToggleDirective implements IToggleView, OnInit, OnDestroy {
219219
this._overlayId = this.overlayService.attach(this.elementRef, overlaySettings);
220220
}
221221

222-
this._collapsed = false;
223-
this.cdr.detectChanges();
224-
225222
const openEventArgs: ToggleViewCancelableEventArgs = { cancel: false, owner: this, id: this._overlayId };
226223
this.onOpening.emit(openEventArgs);
227224
if (openEventArgs.cancel) {
228-
this._collapsed = true;
229-
this.cdr.detectChanges();
230225
return;
231226
}
232227

228+
this._collapsed = false;
229+
this.cdr.detectChanges();
230+
233231
this.unsubscribe();
234232

235233
this._overlayAppendedSub = this.overlayService.onAppended.pipe(...this._overlaySubFilter).subscribe(() => {

projects/igniteui-angular/src/lib/time-picker/time-picker.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ export class IgxTimePickerComponent implements
411411
* @ViewChild("toast")
412412
* private toast: IgxToastComponent;
413413
* public onValueChanged(timepicker){
414-
* this.toast.show()
414+
* this.toast.open()
415415
* }
416416
* //...
417417
* ```
@@ -431,7 +431,7 @@ export class IgxTimePickerComponent implements
431431
* @ViewChild("toast")
432432
* private toast: IgxToastComponent;
433433
* public onValidationFailed(timepicker){
434-
* this.toast.show();
434+
* this.toast.open();
435435
* }
436436
* //...
437437
* ```

projects/igniteui-angular/src/lib/toast/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,25 @@ The Toast component shows application messages in a stylized pop-up box position
77
## Simple Toast
88

99
```html
10-
<button (click)="toast.show()">Show toast</button>
11-
<button (click)="toast.hide()">Hide toast</button>
10+
<button (click)="toast.open()">Show toast</button>
11+
<button (click)="toast.close()">Hide toast</button>
1212

1313
<igx-toast #toast>Well, hi there!</igx-toast>
1414
```
1515

1616
You can set the id of the component by setting the attribute `id` on the component (e.g. `id="myToast"`), or it will be automatically generated for you if you don't provide anything;
1717

18-
The toast can be shown by using the `show()` method.
18+
The toast can be shown by using the `open()` method.
1919

20-
You can hide the toast by using the `hide()` method.
20+
You can hide the toast by using the `close()` method.
2121

2222
## Toast Position
2323
You can set the `positon` property to `top`, `middle`, or `bottom`, which will position the toast near the top, middle, or bottom of the document*.
2424

2525
*By default the toast renders inside a global overlay outlet. You can specify a different overlay outlet by setting the `outlet` property on the toast;
2626

2727
```html
28-
<button (click)="toast.show()">Show toast</button>
28+
<button (click)="toast.open()">Show toast</button>
2929
<igx-toast #toast position="top">Top Positioned Toast</igx-toast>
3030
```
3131

@@ -43,7 +43,7 @@ You can display various content by placing it between the `igx-toast` tags.
4343
## Toast Events
4444

4545
```html
46-
<button (click)="toast.show()">Show toast</button>
46+
<button (click)="toast.open()">Show toast</button>
4747

4848
<igx-toast
4949
#toast

projects/igniteui-angular/src/lib/toast/toast.component.spec.ts

Lines changed: 24 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ describe('IgxToast', () => {
3030
beforeEach(() => {
3131
fixture = TestBed.createComponent(ToastInitializeTestComponent);
3232
toast = fixture.componentInstance.toast;
33-
toast.isVisible = true;
3433
fixture.detectChanges();
3534
});
3635

@@ -41,7 +40,6 @@ describe('IgxToast', () => {
4140
expect(domToast.id).toContain('igx-toast-');
4241
expect(toast.displayTime).toBe(4000);
4342
expect(toast.autoHide).toBeTruthy();
44-
expect(toast.isVisible).toBeTruthy();
4543

4644
toast.id = 'customToast';
4745
fixture.detectChanges();
@@ -51,79 +49,59 @@ describe('IgxToast', () => {
5149
});
5250

5351
it('should auto hide after it\'s open', fakeAsync(() => {
54-
spyOn(toast.onHiding, 'emit');
52+
spyOn(toast.onClosing, 'emit');
5553
toast.displayTime = 1000;
5654

57-
toast.show();
55+
toast.open();
5856
tick(1000);
59-
expect(toast.onHiding.emit).toHaveBeenCalled();
57+
expect(toast.onClosing.emit).toHaveBeenCalled();
6058
}));
6159

6260
it('should not auto hide after it\'s open', fakeAsync(() => {
63-
spyOn(toast.onHiding, 'emit');
61+
spyOn(toast.onClosing, 'emit');
6462
toast.displayTime = 1000;
6563
toast.autoHide = false;
6664

67-
toast.show();
65+
toast.open();
6866
tick(1000);
69-
expect(toast.onHiding.emit).not.toHaveBeenCalled();
67+
expect(toast.onClosing.emit).not.toHaveBeenCalled();
7068
}));
7169

72-
it('should emit onShowing when toast is shown', () => {
73-
spyOn(toast.onShowing, 'emit');
74-
toast.show();
75-
expect(toast.onShowing.emit).toHaveBeenCalled();
70+
it('should emit onOpening when toast is shown', () => {
71+
spyOn(toast.onOpening, 'emit');
72+
toast.open();
73+
expect(toast.onOpening.emit).toHaveBeenCalled();
7674
});
7775

7876
it('should emit onHiding when toast is hidden', () => {
7977
spyOn(toast.onHiding, 'emit');
80-
toast.hide();
78+
toast.close();
8179
expect(toast.onHiding.emit).toHaveBeenCalled();
8280
});
8381

84-
it('should emit onShown when toggle onOpened is fired', waitForAsync(() => {
85-
spyOn(toast.onShown, 'emit');
82+
it('should emit onOpened when toast is opened', () => {
83+
expect(toast.isVisible).toBeFalse();
8684
toast.open();
85+
fixture.detectChanges();
86+
expect(toast.isVisible).toBeTrue();
87+
});
8788

88-
toast.onOpened.subscribe(() => {
89-
expect(toast.onShown.emit).toHaveBeenCalled();
90-
});
91-
}));
92-
93-
it('should emit onHidden when toggle onClosed is fired', waitForAsync(() => {
94-
spyOn(toast.onHidden, 'emit');
95-
toast.isVisible = true;
96-
toast.close();
97-
98-
toast.onClosed.subscribe(() => {
99-
expect(toast.onHidden.emit).toHaveBeenCalled();
100-
});
101-
}));
102-
103-
it('visibility is updated by the toggle() method', waitForAsync((done: DoneFn) => {
104-
toast.autoHide = false;
105-
106-
toast.toggle();
107-
toast.onOpened.subscribe(() => {
108-
expect(toast.isVisible).toEqual(true);
109-
});
110-
89+
it('visibility is updated by the toggle() method', () => {
90+
expect(toast.isVisible).toBeFalse();
11191
toast.toggle();
112-
toast.onClosed.subscribe(() => {
113-
expect(toast.isVisible).toEqual(false);
114-
done();
115-
});
116-
}));
92+
fixture.detectChanges();
93+
expect(toast.isVisible).toBeTrue();
94+
});
11795

11896
it('can set message through show method', fakeAsync(() => {
11997
toast.displayTime = 100;
12098
toast.autoHide = false;
12199

122-
toast.show('Custom Message');
100+
toast.open('Custom Message');
123101
tick(100);
124102
fixture.detectChanges();
125-
126103
expect(toast.isVisible).toBeTruthy();
104+
127105
expect(toast.autoHide).toBeFalsy();
128106
expect(toast.toastMessage).toBe('Custom Message');
129107
}));
@@ -136,3 +114,4 @@ class ToastInitializeTestComponent {
136114
@ViewChild(IgxToastComponent, { static: true })
137115
public toast: IgxToastComponent;
138116
}
117+

0 commit comments

Comments
 (0)