feat(AlertGroup): Introduce Alert Group component - #1136
Conversation
|
Deploy preview for pf-next ready! Built with commit d15739c |
My 2 cents, from looking at the designs, I don't think we would want a scrollbar. Looks like the list will only show 3 alerts at a time, and if there are more than 3, the 3rd one says to use the notification drawer. So I don't think there will ever be more than 3 there. I suppose that is the UI to use for both toast and inline alert lists? This is also probably a question for @mcarrano and/or kyle/michael. |
|
I like the use of What do you think about this instead... Except replace the |
|
@andybraren @mcoker There definitely should not be a scrollbar. Theoretically you could stack as may notifications as you want, but we would never advise more than 3. I'm curious about the thinking behind making this a component. Is this intended as a general container that I put a toast alert in? So if I only have a single alert, do I start with a group of one and then add other alerts to it? |
mcoker
left a comment
There was a problem hiding this comment.
Great job! Looks really good. Just a few comments - let me know if you have any questions.
@mcarrano good question. As I understand it, the way it is now, this would be the container for all toast alerts, to position them in the top/right, whether you have one or 30. However a single inline alert can still be displayed on the page inside the alert group component or just on its own outside of the alert group component, and the alert will look the same visually. But if you have more than 1 inline alert, you would want them to be in the alert group to get the vertical spacing. Does that sound ok? |
|
Thanks for the clarification @mcoker . I think that all makes sense. It might be good to document that somewhere in the description so consumers understand what this is and how to use it to position toast notifications. There is an issue in the backlog for an Alert and Notification demo that should also help clarify this. #625 |
|
I guess the scrollbar question could be re-phrased: Should AlertGroup provide an ugly-yet-functional safety net (scroll functionality) to assist users if/when developers fail to implement their notification system exactly as we've designed? I can see why we lean toward no, but I also wonder what % of devs will actually implement the collapsing "Max 3" design in the real world given the seemingly more complex JS logic involved. If we can provide solid React/JS code that works out of the box like everything else that's great, but I don't know enough about that world to scope out how difficult that will be. |
f5bbb61 to
9675db7
Compare
| {{#> alert-group}} | ||
| {{#> alert-item}} | ||
| {{#> alert alert--modifier="pf-m-success" alert--attribute='aria-label="Success Notification"'}} | ||
| {{#> alert-icon alert-icon--success="true"}} |
There was a problem hiding this comment.
@srambach taught me a cool thing today. If you checkout the handlebars partials docs, you'll see there are basic partials and block partials. Basic is when there is no content in the partial (you're just including a partial), and block is when you include content with the partial. So with....
{{#> alert-icon alert-icon--success="true"}}
{{/alert-icon}}
You can just write {{> alert-icon alert-icon--success="true"}}
#sarahisagenius
|
@andybraren good question about the scrollbar. I think my preference would be that we don't include a scrollbar and if there are more than 3 alerts, they will just continue to stack and grow the height of the container. This gives a project using this an option of showing all notifications, even though I wouldn't recommend that, or setting some other criteria for showing or hiding the notifications. Thoughts? |
|
@mcarrano I'm okay with that, and this component supports that behavior as-is, it'll just look like this (unscrollable, bottom-most alert cut off until a higher-up alert is dismissed): |
|
After discussing this PR with @gdoyle1 and @mcarrano there are two more updates to make:
|
|
Updated the visuals here to match the implementation as well @andybraren ! |
|
I've updated this PR to address the above, but Toast Alerts won't quite match the visual design until the following issues are addressed:
|
|
@andybraren I don't really have a strong opinion on using the blue info type instead of the grey one designed - the intent of designating that alert with a distinct color was because it only applies to a single use case. Although, I do think that use case would generally fall under the category of "info" alerts. @mcarrano Do you think this falls under "general informational messages"? |
|
@andybraren @gdoyle1 a couple of comments... I think that we should stick with the blue info color for this alert as we are not using that grey color anywhere else for an alert. @kybaker , any problem with that? Not sure why gray was used in the original visual. In this case, I'm questioning whether both 'View all' and 'X' should both be there. I know we said the user sure always be able to dismiss a toast notification, but I see this as a special case. The third toast should disappear on it's own when there are 3 or less actual notifications either because the user cleared them or because they expired. Does that make sense? |
|
@mcarrano I get your point with removing the 'x' on the last toast, but would only say that if it does not have an 'x' then it wouldn't follow the documentation we have on toasts. I don't really see a harm in leaving the 'x' there in case the user wants to immediately dismiss that toast before the other two on top of it. Otherwise, if they were to just 'x' out one on top (or one were to disappear on top), that last toast would disappear automatically (I think that was what you were saying). |
|
@mcarrano @gdoyle1 As an impatient user I wouldn't enjoy having to either wait 8 seconds or click more than 3 X's to make all toasts go away. I'd vote for always having an X, even on the special third toast. And to clarify the behavior of that special third toast, looking at this image for example: Are we saying that dismissing/closing the second red toast would make the third blue toast dissolve and reveal the remaining two (older) notifications? I wonder if triaging 4+ notifications two at a time like that will feel better than keeping the third toast static as just a heads-up that there are # more alerts in the notification drawer. I also wonder what the animations should be if/when the special toast goes poof. |
|
@andybraren and @gdoyle1 these are all good points. I just finished a conversation with @matthewcarleton about all of this and we agreed that it may be time to rethink the design of this a bit. There is clearly more complexity to the toast aggregation than initially considered. At the same time we want to avoid adding more complexity to the Alert component itself. I am going to set up a meeting so we can talk through this live and consider alternatives for keeping this moving forward. |
"Dismiss" sounds like the right action word for the Alerts in a group. Also, in similar patterns like ChipGroup and DataList where items in a list have the same action, we're also labeling the action with the main text of that item. This is helpful for providing context for buttons that otherwise would have identical labels. For example, the remove button in a chip has the following attributes: If the Chip label is "Puppies", the button is announced as:
In this case, the dismiss button should reference the heading element of the Alert: And the combination of the Dismiss label and the heading text would be announced as:
But I'd love some suggestions on refinements to this. Like should we include the word "alert" in the hidden text (i.e. "Success alert:"), should we drop the heading text and only reference the type of alert (e.g. "Dismiss Success alert: button") and rely more on context for clarification to avoid potentially really long buttons labels? Given the number of alerts that could display and the likeliness that they would be removed automatically, I don't imagine there being a large number of any one type of alert anyway. I'm cc'ing @stacymcauliffe in case she has input, too. |
|
@jgiardino - So, in order, the user would hear something like - "Success: Files are uploaded" (plus maybe something that indicates to them that this is an alert) and then when they navigate to the next element, "Dismiss Success Files are uploaded button" or "Dismiss success alert button"... I think it would be enough to read "Dismiss success alert button" but it's hard to say definitively without understanding how easy it is for context to be lost/forgotten. I would imagine they'd be hearing the information contained in the alert message and then immediately either clicking a CTA/action button in the alert or simply dismissing. |
|
Yes. There's also the case where they're only scrolling through all the buttons on the page. So they could hear: "Dismiss Success alert button" If they're navigating by button, they could shift focus to the previous/next element next to that button to get a sense of context. But they would need to somehow know when they're on a button whether that alert text that comes before it or after it is the alert they're dismissing, which could be challenging. I'm still really on the fence with this, but for that reason I slightly lean toward the more verbose, obvious method of labeling. When you say
|
|
Thanks for making these updates! There were a couple of things I noticed:
|
59a0ba1 to
33c040c
Compare
|
I’ve updated this PR to:
I’ve also created a new issue #1226 to propose some small updates we should consider making to the Alert component. |
|
Your updates look good! And thanks for opening #1126! I'm not able to identify what changes were made as part of
Is there a specific commit where this change was made? I'd like to see what the documentation is. Currently I don't see anything about the Dismiss button specifically. Maybe it's there and I can't find it, or maybe it's something we can note in #1126. |
|
@jgiardino Sorry, I mis-wrote, it turns out the "redundant accessibility documentation" was about the screen reader class/utility and not related to the close buttons (whose
This was basically the same as the Alert component's accessibility documentation, but also noted that it should call itself a "notification" rather than an alert. We've agreed to not do that, making the above redundant with what's in the Alert component today, so I removed it and replaced it with:
Although based on the discussion happening in #1226 the location of And you're right that I haven't documented the Edit: I've fixed the issues above for the sake of keeping AlertGroup and Alert in sync. Close buttons now have
|
Props to mcoker! The distance between the toast group and top/right edges is now set by top and right instead of padding, eliminating the need for those variables. This also eliminates the need to mess with pointer-events.
Alerts themselves are already display:flex which makes them fill and push the width of this containing .pf-c-alert-group. The extra width definition seems unnecessary.
Now uses the “owl selector” and margin-top to specify spacing between alerts.
Alert groups are basically lists of alerts, so div has been switched to ul with li items containing each individual alert.
.pf-c-alert-group is only necessary when more than one alert is used, or when used for toast notifications.
Now includes the unique third toast with a secondary action button that opens the notification drawer. Documentation now specifies that actions, links, and buttons should not be included within toast alerts except for the unique third one.
After some design discussions, the unique third combo-notification is being reworked so it’s removed from this example.
Every toast needs a close button.
Adds aria-labelledby to buttons referring to the notification’s heading and clarifies that screen reader text should refer to toasts as notifications.
The word "notification" has been replaced with "alert" in all cases, including id. The phrase "Toast Alert" is used in the toast alert’s aria-label.
Removed duplicate role=alert from pf-c-alert, leaving the one on pf-c-alert__body. Also changed aria-label of close buttons to Close from Dismiss to align with the Alert component as it is today.
Trying to keep what we call these things consistent everywhere.
|
🎉 This PR is included in version 1.0.124 🎉 The release is available on: Your semantic-release bot 📦🚀 |





Alert Groups are used to contain and align consecutive alerts, either inline alongside a page's content or in the top-right corner as toast notifications.
This implementation is based on this visual design:
Implementation notes
The width of a toast group is set by
--pf-c-alert-group--MaxWidthwith an initial value of 600px. Regular alert groups are fullwidth.Padding is used to space the toast group in the corner and keep it centered in smaller viewports.
pointer-events: none;allows users to click through that padding (to click nav items, tabs, etc.) andpointer-events: initial;is applied to the group’s direct children to make sure alerts themselves are still clickable.Questions
bottomandleft.box-shadowaround individual alerts makes any scrollbar position look awkward.Closes #654.