allianz / ng-aquila

Angular UI Component library for the Open Insurance Platform
https://allianz.github.io/ng-aquila/
Other
213 stars 38 forks source link

[Message Toast] Adjustment contextual type of a message #72

Closed AntonLie closed 1 month ago

AntonLie commented 1 month ago

⚡ Reproduction As a developer, I want a message toast with an error context style.

Steps to reproduce:

  1. Create Message Toast
  2. Add context NxMessageToastContext with 'error'.

Create a Message Toast. Add context NxMessageToastContext with the value 'error'. 📗 Expected Behavior

I expect the NxMessageToastContext to display with an error style.

Screenshot 2024-10-14 at 14 02 08

I added the type to avoid errors like this:

Screenshot 2024-10-14 at 13 37 39

I suggest adding the type:

Screenshot 2024-10-14 at 14 06 34

📕 Actual Behavior Received the error: Type '"error"' is not assignable to type 'NxMessageToastContext | undefined'.

📦 Environment

Aquila/NDBX version: 17.1.2 Angular/CDK version: 17.0.0 Browser name & version: Google Chrome Version 129.0.6668.91 Operating System & version (desktop or mobile): Desktop

Phil147 commented 1 month ago

Hi @AntonLie this is not a bug but intentional. The Design System guidelines state that only optional information should be shown as a toast and critical information like warnings and errors should be shown statically on the page (inline) as message toasts can disappear either after a short time or by another toast and the information would be lost without the user being able to see or react to it. That's why warnings and errors are not allowed by NxMessageToastContext.

'error' as NxMessageToastContext works because under the hood the toast reuses our own nx-message component which accepts all contexts. The type in this case guides you what you are supposed to do. What you are doing is technically possible but from UX and design guidelines not wanted inside Allianz.