akveo / akveo/nebular

Bad toast notification placement

Open
#2,281 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
8.1k
Forks
1.5k
PR merge metrics
No merged PRs in 30d

Description

### Issue type

**I'm submitting a ...** (check one with "x")

* [X] bug report
* [ ] feature request

### Issue description

**Current behavior:**
Calling NbToastrService from a GlobalErrorHandler to build a toast notification (NbToastrModule is configured in app.module to show in TOP_RIGHT position), but shows in TOP_LEFT on first toast notif. The second one is displayed correctly

**Expected behavior:**
Should display toast notification in specified position.

**Steps to reproduce:**

**Related code:**

```
@Injectable()
export class GlobalErrorHandler implements ErrorHandler {

constructor(
private toastrService: NbToastrService
) {
}

getClientErrorMessage(error: Error): string {
return error.message ?
error.message :
error.toString();
}

getServerErrorMessage(error: HttpErrorResponse): string {
if (navigator.onLine) {
return error.error ? error.error[0].message : error.message;
}
return 'No Internet Connection';
}

handleError(error: Error | HttpErrorResponse) {
let message;
if (error instanceof HttpErrorResponse) {
// Server error
message = this.getServerErrorMessage(error);
} else {
// Client Error
message = this.getClientErrorMessage(error);
}
this.toastrService.danger(message, 'Error', {position: NbGlobalPhysicalPosition.TOP_RIGHT});
console.error(error);
}
}
```

### Other information:

**npm, node, OS, Browser**
```

```

**Angular, Nebular**
```
"@angular/core": "~9.0.5"
"@nebular/theme": "4.6.0"
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.