Skip to content
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

fix(toast): isVisible property binding - master #8775

Merged
merged 25 commits into from
Jan 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
c679e78
fix(toast): isVisible property binding - master
dobromirts Jan 12, 2021
0b57ad9
chore(*): add additional test
dobromirts Jan 13, 2021
710dfce
chore(*): add additional test
dobromirts Jan 13, 2021
293334c
Merge branch 'master' into dTsvetkov/fix-8207-master
hanastasov Jan 13, 2021
72b00fb
chore(*): refactor toggleDirective
dobromirts Jan 14, 2021
1b68bd7
chore(*): fix toast tests
dobromirts Jan 14, 2021
27887b7
chore(*): toggleDirective changes
dobromirts Jan 15, 2021
35b9452
chore(*): addtitional toggle changes
dobromirts Jan 15, 2021
7c34aea
Merge branch 'master' into dTsvetkov/fix-8207-master
hanastasov Jan 18, 2021
b99c779
chore(*): remove detectChanges from toggle
dobromirts Jan 18, 2021
c686c2f
Merge branch 'master' into dTsvetkov/fix-8207-master
hanastasov Jan 18, 2021
1987944
chore(*): deprecate events
dobromirts Jan 18, 2021
a72990d
Merge branch 'dTsvetkov/fix-8207-master' of https://github.com/Ignite…
dobromirts Jan 18, 2021
e30042e
chore(*): fix lint errors
dobromirts Jan 18, 2021
c82584f
chore(*): add DeprecateMethods
dobromirts Jan 18, 2021
86b8103
Merge branch 'master' into dTsvetkov/fix-8207-master
dobromirts Jan 18, 2021
95ccf41
chore(*): add changelog info
dobromirts Jan 19, 2021
8588fd0
chore(*): change toast migration
dobromirts Jan 19, 2021
2b12cea
chore(*): change toast migration
dobromirts Jan 19, 2021
77bb8bc
Merge branch 'master' into dTsvetkov/fix-8207-master
zdrawku Jan 19, 2021
3f8cbcd
Merge branch 'master' into dTsvetkov/fix-8207-master
hanastasov Jan 19, 2021
137955a
test(toast): remove subscriptions
dobromirts Jan 19, 2021
703ef73
test(toast): fix failed tests
dobromirts Jan 20, 2021
d57f029
Merge branch 'master' into dTsvetkov/fix-8207-master
dobromirts Jan 20, 2021
0dea207
Merge branch 'master' into dTsvetkov/fix-8207-master
hanastasov Jan 20, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ All notable changes for each version of this project will be documented in this
- Added new property `alignment` that determines the radio group alignment. Available options are `horizontal` (default) and `vertical`.
- `IgxDialog`
- Added new `onOpened` and `onClosed` events.
- `IgxToast`
- **Breaking Change** -
`show` and `hide` methods have been deprecated. `open` and `close` should be used instead.
`onShowing`,`onShown`,`onHiding` and `onHiden` events have been deprecated. `onOpening`, `onOpened`, `onClosing` and `onClosed`should be used instead.
- `IgxInputGroup`
- Added new property `theme` that allows you to set the theme explicitly and at runtime.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ export class IgxButtonGroupComponent extends DisplayDensityBase implements After
* @ViewChild("toast")
* private toast: IgxToastComponent;
* public onSelect(buttongroup){
* this.toast.show()
* this.toast.open()
* }
* //...
* ```
Expand All @@ -233,7 +233,7 @@ export class IgxButtonGroupComponent extends DisplayDensityBase implements After
* @ViewChild("toast")
* private toast: IgxToastComponent;
* public onUnselect(buttongroup){
* this.toast.show()
* this.toast.open()
* }
* //...
* ```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,17 +219,15 @@ export class IgxToggleDirective implements IToggleView, OnInit, OnDestroy {
this._overlayId = this.overlayService.attach(this.elementRef, overlaySettings);
}

this._collapsed = false;
this.cdr.detectChanges();

const openEventArgs: ToggleViewCancelableEventArgs = { cancel: false, owner: this, id: this._overlayId };
this.onOpening.emit(openEventArgs);
if (openEventArgs.cancel) {
this._collapsed = true;
this.cdr.detectChanges();
return;
}

this._collapsed = false;
this.cdr.detectChanges();

this.unsubscribe();

this._overlayAppendedSub = this.overlayService.onAppended.pipe(...this._overlaySubFilter).subscribe(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ export class IgxTimePickerComponent implements
* @ViewChild("toast")
* private toast: IgxToastComponent;
* public onValueChanged(timepicker){
* this.toast.show()
* this.toast.open()
* }
* //...
* ```
Expand All @@ -431,7 +431,7 @@ export class IgxTimePickerComponent implements
* @ViewChild("toast")
* private toast: IgxToastComponent;
* public onValidationFailed(timepicker){
* this.toast.show();
* this.toast.open();
* }
* //...
* ```
Expand Down
12 changes: 6 additions & 6 deletions projects/igniteui-angular/src/lib/toast/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,25 @@ The Toast component shows application messages in a stylized pop-up box position
## Simple Toast

```html
<button (click)="toast.show()">Show toast</button>
<button (click)="toast.hide()">Hide toast</button>
<button (click)="toast.open()">Show toast</button>
<button (click)="toast.close()">Hide toast</button>

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

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;

The toast can be shown by using the `show()` method.
The toast can be shown by using the `open()` method.

You can hide the toast by using the `hide()` method.
You can hide the toast by using the `close()` method.

## Toast Position
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*.

*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;

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

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

```html
<button (click)="toast.show()">Show toast</button>
<button (click)="toast.open()">Show toast</button>

<igx-toast
#toast
Expand Down
69 changes: 24 additions & 45 deletions projects/igniteui-angular/src/lib/toast/toast.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ describe('IgxToast', () => {
beforeEach(() => {
fixture = TestBed.createComponent(ToastInitializeTestComponent);
toast = fixture.componentInstance.toast;
toast.isVisible = true;
fixture.detectChanges();
});

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

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

it('should auto hide after it\'s open', fakeAsync(() => {
spyOn(toast.onHiding, 'emit');
spyOn(toast.onClosing, 'emit');
toast.displayTime = 1000;

toast.show();
toast.open();
tick(1000);
expect(toast.onHiding.emit).toHaveBeenCalled();
expect(toast.onClosing.emit).toHaveBeenCalled();
}));

it('should not auto hide after it\'s open', fakeAsync(() => {
spyOn(toast.onHiding, 'emit');
spyOn(toast.onClosing, 'emit');
toast.displayTime = 1000;
toast.autoHide = false;

toast.show();
toast.open();
tick(1000);
expect(toast.onHiding.emit).not.toHaveBeenCalled();
expect(toast.onClosing.emit).not.toHaveBeenCalled();
}));

it('should emit onShowing when toast is shown', () => {
spyOn(toast.onShowing, 'emit');
toast.show();
expect(toast.onShowing.emit).toHaveBeenCalled();
it('should emit onOpening when toast is shown', () => {
spyOn(toast.onOpening, 'emit');
toast.open();
expect(toast.onOpening.emit).toHaveBeenCalled();
});

it('should emit onHiding when toast is hidden', () => {
spyOn(toast.onHiding, 'emit');
toast.hide();
toast.close();
expect(toast.onHiding.emit).toHaveBeenCalled();
});

it('should emit onShown when toggle onOpened is fired', waitForAsync(() => {
spyOn(toast.onShown, 'emit');
it('should emit onOpened when toast is opened', () => {
expect(toast.isVisible).toBeFalse();
toast.open();
fixture.detectChanges();
expect(toast.isVisible).toBeTrue();
});

toast.onOpened.subscribe(() => {
expect(toast.onShown.emit).toHaveBeenCalled();
});
}));

it('should emit onHidden when toggle onClosed is fired', waitForAsync(() => {
spyOn(toast.onHidden, 'emit');
toast.isVisible = true;
toast.close();

toast.onClosed.subscribe(() => {
expect(toast.onHidden.emit).toHaveBeenCalled();
});
}));

it('visibility is updated by the toggle() method', waitForAsync((done: DoneFn) => {
toast.autoHide = false;

toast.toggle();
toast.onOpened.subscribe(() => {
expect(toast.isVisible).toEqual(true);
});

it('visibility is updated by the toggle() method', () => {
expect(toast.isVisible).toBeFalse();
toast.toggle();
toast.onClosed.subscribe(() => {
expect(toast.isVisible).toEqual(false);
done();
});
}));
fixture.detectChanges();
expect(toast.isVisible).toBeTrue();
});

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

toast.show('Custom Message');
toast.open('Custom Message');
tick(100);
fixture.detectChanges();

expect(toast.isVisible).toBeTruthy();

expect(toast.autoHide).toBeFalsy();
expect(toast.toastMessage).toBe('Custom Message');
}));
Expand All @@ -136,3 +114,4 @@ class ToastInitializeTestComponent {
@ViewChild(IgxToastComponent, { static: true })
public toast: IgxToastComponent;
}

Loading