#385: A toast UI element
Discussions
Comment by @markcellus Jun 12, 2019 (See Github)
Something like this definitely needed. The std-
prefix and shipping this as a built-in module was an interesting choice rather than making this a Custom Element and shopping it around in userland and gaining some public interest first. Were you planning for this to be shipped as part of the proposed standard library?
Comment by @jackbsteinberg Jun 12, 2019 (See Github)
Hey @mkay581 thanks for taking a look at this.
The intention here is to create a new HTML element, going through the usual process that requires, and using a std-
prefix to preserve faithful polyfillability. Instead of creating a Custom Element and adding to the variety of toast implementations out there, we think it's more valuable to bake the popular toast pattern right into the language, allowing those libraries to decrease their bundle sizes by building their toasts right on top of ours.
@domenic's latest comment in this thread on the std-switch
Intent to Implement might provide some helpful context.
Comment by @othermaciej Jun 13, 2019 (See Github)
Problems with this approach (also applicable to std-switch
):
-
I think we need to find a way to avoid most/all future HTML elements having a
std-
prefix. It will make HTML quite unpleasant to read if we project out a decade or so. -
Having to do an import per-element doesn't seem like it scales well.
It's worth thinking about these problems and trying to solve them before creating too many elements with this pattern.
Comment by @dbaron Jun 13, 2019 (See Github)
A bunch of the discussion in #384 likely applies here as well.
Comment by @philiprenich Jun 13, 2019 (See Github)
(Not actually sure if this repo is meant for general public commenting, sorry...)
HTML elements are meant to be single words with no -
aren't they? Toast
is also an esoteric cutsie name that probably doesn't belong in the spec. Surely something more meaningful can be found? Not an easy task for sure, it's an overloaded space :/
Comment by @othermaciej Jun 13, 2019 (See Github)
"Toast" seems like the standard term for expiring non-modal notification windows on Android and Windows. On iOS and MacOS they are called "banners", or if you want to be really specific, "temporary notification banners".
I guess the intention here is to provide an in-page version of this functionality, which is why it's new stuff instead of additions to Notifications API.
I do think "toast" is a an odd jargon term that will be really clear in some communities and really confusing in others.
Another thought: why isn't this instead an addition to <dialog>
, a showTemporary()
(or showToast()
or showBanner()
) method in addition to show()
and showModal()
? It seems like that could be implemented on top of show()
, close()
and a timer, so still polyfillable, and wouldn't be semantically wrong IMO.
Comment by @kenchris Jun 13, 2019 (See Github)
As a non-English speaker, I don't find banner any more clear. Especially banner (I think flag like thing) is often used as a loanword with very specific meaning (toast as well which is normally a heated sandwich and just that). As a non-English speaker, words like tooltip are just as bad, but you learn exactly when they represent quickly, so I don't think the name is a big blocker.
I think something like infobox
(or infobanner
for that matter) might be more understandable to most people - it is just info, so not super important and thus, it might go away after a short while
Comment by @boazsender Jun 13, 2019 (See Github)
Thanks for requesting feedback @jackbsteinberg.
I really appreciate the intention behind this proposal: to pave web developer cow paths 🐄, and to make more accessible defaults🤗. At the same time, I was surprised to see this API being developed separately from the notifications API and <dialogue>
. Would it be worth exploring extending one or both of those interfaces first? We probably want to avoid web authors needing to learn three different interfaces for giving user advice or feedback. I also understand that we don't want to make web authors contort themselves to give so called "toast" with a modified dialogue or notifications interface. There must be a happy middle ground. I recognize that what I'm suggesting here is a lot more work for you/us, but I think it will make for an easier-to-reason-about feedback/advice interface. What do you think?
Separately, I also agree with previous commenters that "toast" feels too platform specific for the web, and that the std prefix won't age well.
Thanks again for working on improving the web platform! I think there is a ton of potential here to make the web a stronger and more accessible platform. I am extra appreciative of your time working on toast, reviewing feedback, and building consensus with TAG, web developers and multiple implementers.
Comment by @zcorpan Jun 13, 2019 (See Github)
<std-toast>
seems to not be so well-received (example), as if Google is somehow skipping standardization and forcing their solution on everyone.
Consider following the "problem-statement-first" WHATWG process. This builds consensus through public discussion of the problem prior to proposing a solution.
Comment Jun 13, 2019 (See Github)
according to this page:
https://developer.mozilla.org/Web/HTML/Element
i am counting at least 200 HTML elements currently (forgive if my selector is bad):
$$('td [href^="/en-US/docs/Web/HTML/Element/"]').length;
223
are we really saying that none of the current elements can fill this role? I agree with @zcorpan, this seems like a vanity project and should go through the normal process. not be rushed through "because google".
Comment by @crertel Jun 13, 2019 (See Github)
Relevant time constraints or deadlines: Great if the review is done by the end of August 2019
This wouldn't happen to be motivated by, say, a return to class for the fall semester?
Anyways, some questions.
<std-toast id="sample-toast" theme="info">
Hello World!
</std-toast>
- What is the purpose of the
theme
attribute? - What are the valid values of the
theme
attribute? Are custom themes supported? - What markup is allowed inside
<std-toast>
elements? The docs suggest that toasts contain an image, some text, and maybe some interaction, but does the markup allow for more interesting things? Text styling? ARIA markup? - How does accessibility work for toasts, anyways?
import { showToast } from 'std:elements/toast';
const toast = showToast("Hello World!", {
theme: "info",
duration: 3000
});
- What markup is allowed in the first param to
showToast
? Can we pass a DOM element instead? - Is there any provision to prevent malicious scripts from filling a user's screen with obnoxious amounts of toast?
- What happens to toast created in
iframe
elements?
Thanks for starting a discussion, anyways!
Comment by @kenchris Jun 13, 2019 (See Github)
Hi @crertel can you please file these issues on the project/spec repo, so they get properly tracked.
This wouldn't happen to be motivated by, say, a return to class for the fall semester?
Please avoid sarcasm and/or ironi in this repo, and keep the discussion focused
Comment by @domenic Jun 13, 2019 (See Github)
I've posted https://github.com/whatwg/html/issues/4696 and https://github.com/whatwg/html/issues/4697 to centralize discussion around polyfillable element names and pay-for-what-you-use HTML elements. A lot of the other things folks have mentioned in this issue are already being discussed in the std-toast repo, which is great; that's why we file for feedback early!
Comment by @torgo Jun 14, 2019 (See Github)
@jackbsteinberg I'd like to see @boazsender's question addressed : why is this separate from the notifications API?
Comment by @torgo Jun 14, 2019 (See Github)
Also regarding venue, what is the roadmap to bring this to WICG or similar?
Comment by @kenchris Jun 14, 2019 (See Github)
@torgo the difference is that this is a temporary notification / infobar, like you see for PWAs ("new version available, press reload to refresh") or like in GMail ("Chat is currently unavailable") etc. These are not things you want an actual system notification for... They really depend on the surrounding content/situation unlike regular notifications
Comment by @garygreen Jun 14, 2019 (See Github)
import { showToast } from 'std:elements/toast';
const toast = showToast("Hello World!", {
theme: "info",
duration: 3000
});
Does this format not completely deviate from API currently in browsers? It looks to me Google is proposing to overload imports and stub in their own. This would make it difficult to polyfill in older/non supported browsers, too?
I also echo the comments from others that it feels like an existing element e.g <dialog>
could be used to house the toast-like functionality and keep to standards already defined rather than create a new concept of tags prefixed with "std" e.g. <std-toast>
Having a way to define and position popups/toasts around other elements is long overdue. Maybe cc/ @FezVrasta can also share his thoughts on this proposal (author of Popper.js)
Comment by @garygreen Jun 14, 2019 (See Github)
Ok I think I've totally misunderstood the point of this new toast proposal. The name is very confusing. I was thinking it was to do with adding tooltip positioning-like functionality in the browsers, like Popper but it looks like this is more to do with dialogs e.g. Sweet Alert ?
I was hoping for some kind of positoning engine native to browers so you can position things like the way it's described in the proposal:
Meh. This whole thing doesn't seem as useful now as it seem so specific and opinionated, plus the functionality does overlap with <dialog>
.
Comment by @FezVrasta Jun 14, 2019 (See Github)
I think OP refers to the elements known as "Snackbars" in Google Material Design?
Comment by @garygreen Jun 14, 2019 (See Github)
@FezVrasta
I think OP refers to the elements known as "Snackbars" in Google Material Design?
Yes I think so, and also an alert with icons, close buttons, theme, etc. It all seems pretty opinionated to me. Sorry for including you in on this I thought it was something to do with tooltips and positioning elements in the browser, that got me a bit excited but seeems this is for something totally different.
Comment by @FezVrasta Jun 14, 2019 (See Github)
Having a browser provided API to position elements would be great 🙂 I'll keep dreaming
Comment by @domenic Jun 14, 2019 (See Github)
@torgo we have an issue filed to clarify about the notifications API, and will do that in the explainer ASAP. But in the meantime, @kenchris is right on. This is an established UI pattern that is about transient things, not things you want in your system notifications tray.
Regarding venue, we are hoping to bring to WICG ASAP as well. It seems like there's some positive support in the Discourse thread, so I think the prerequisites are met there, so we can move as soon as the relevant people with admin rights are able to do the switch.
Comment by @crertel Jun 15, 2019 (See Github)
Please avoid sarcasm and/or ironi in this repo, and keep the discussion focused
No sarcasm or irony intended--it's useful to know the provenance of a proposal so as to have an idea how "serious" it is, and also how likely it is to be maintained.
Comment by @OwenEdwards Jun 17, 2019 (See Github)
How does accessibility work for toasts, anyways?
I second that concern. For example, how long is an appropriate timeout for accessibility, and what other features of this proposed element affect its accessibility? Should it have an implicit ARIA role (something like "alert")? These are just a few points that immediately come to mind.
Discussed
Jun 19, 2019 (See Github)
Kenneth: There's a lot of meta things about this. This also ties into switch
. A lot of discussion has happened already. This one was controversial not least because of the name
Dan: Yeah I don't get why it needs to be a standard component, why not just write JS to do it.
Kenneth: the explainer covers this... one reason is having multiple toast libraries on the page ... accessibility
discussion of name, inevitably
David: There is more to discuss here about how we introduce new elements to HTML. There's a lot going on with that plan that I think we should look at.
... Web components did this thing where you need a dash in the name, and now we're making the new elements have dashes in their name. What's the theory behind this, when do you use it? Why do we need to use an import? Is that syntax real TC39 Syntax?
Tess: Each of these proposals build on and depend on a bunch of other pieces that are either not there or don't have clear consensus or aren't fleshed out. It's a little hard to do specific reviews when so many underlying assumptions are not clearly going to eventuate.
... it feels a little futile to debate this one element if those things may not come to fruition.
Kenneth: Well the same UI may be surfaced a slightly different way...
Dan: What happened to incubation? This is why I want to have this discussion at TPAC. The Extensible Web Manifesto ... marketplace of ideas ... this seems to assume that that discussion doesn't need to happen in public.
Alice: There is a bit of a misunderstanding of the weight that intent to implement carries.
Tess: these elements don't strike me as a fait accompli, but the underlying assumptions do.
... Domenic asked questions about whether new elements should be fully polyfillable? The HTML community can address these issues at that issue, but I wish those issues had been filed first. I'm happy to see that he agrees that we haven't come to that conclusion either
Kenneth: I think the intent was to drive that precise discussion. I agree that this should have gone to WICG before coming to i2i and TAG review.
Sangwhan: It seems a bit dangerous that they're going straight to the standard namespace.
Tess: It's not even that, it has a js-
prefix in the JS library and the element has an <std-
prefix. My understanding is that Domenic intends this to be owned by HTML.
Sangwhan: If we decided on std
as the new standard namespace - why are these going straight into that namespace without incubation? (e.g. why is there no TR1?)
Tess: I think there is a third question... Domenic raised an issue on whether ... DOM level stuff. My understanding is that it (?) wasn't. My understanding of the JS standard library is that it should be equally usable in non-web contexts. So it felt weird to use that mechanism for adding DOM API.
Kenneth: I think it was intended for web stuff as well, like the KV store.
Tess: That one surprised me as well.
... My impression from msaboff was that it was for things usable across all javascript contexts.
Dan: Can somebody take some time to boil down this discussion into an issue comment?
... Domenic mentioned they're hoping to bring it to WICG... extending notifications ....
... What can we do right now besides summarising our discussion here, to push this along?
Kenneth: I'm not clear on whether they are interested in review on the actual element, rather than the underlying things?
Dan: Are you interested to do that?
Kenneth: other than the name...
Alice: Name is a bikehed honeytrap. I have a11y thoughts. I think it's an antipattern; it's difficult to make accessible complete sense. I spent time working on this with a colleague (Chrome UI bookmarks page). We wished it wasn't there but did our best. You can make an accessible version of an inaccessible pattern, but the pattern is not great.
Kenneth: but people are using the pattern all over; otherwise just not accessiible by default.
Alice: so what kind of sad bargain do we need to strike there?
Kenneth: I'd love to have an a11y expert look at this.
Alice: It's not, but you can fudge it to be kind of accessible for some people.
Kenneth: ... if you give it focus ...
Tess: focus seems like an obvious case of its inaccessibility. Does it popping up change where the screenreader is focused?
Alice: screenreader isn't the worst of it; worst part is zoom.
Alice: I've been waiting for the rush of attention around process issues before getting into it.
Sangwhan: I have technical feedback on ...
Tess: Seems like it should be a mode in the notifications api; then you can rely on system a11y.
Kenneth: these notifications are much more tied to the content; when you've surfed to something else they don't matter anymore.
Dan: We're ratholing into designing the feature. I think we ought to end the timebox here.
Sangwhan: I don't think we can summarize without agreement on what we want to say.
Dan: We've brought up different issues; they can be asked.
Kenneth: I think a11y should be raised.
Alice: Issue has been snarky so far; we should try to be extra kind.
Kenneth: I can make a comment ...
Dan: I think we should continue this discussion in comments. We have 15 minutes left, I'd like a two minute discussion on each of the other agenda issues.
Comment by @kenchris Jun 19, 2019 (See Github)
We talked a bit about this in the TAG today. The feature seems to be an accessibility anti-pattern, according to the accessibility folks on the team, but that of course won't stop people from using the "toasts/banners" on their sites, so if a standardized toast can improve the accessibility story that is a net win.
That said, we are very interested in hearing now the std-toast will handle accessibility, as it is presumable out of the accessibility tree and might even interrupt and confuse the user. For instance the screen reader might be reading a particular section, and interrupting that could be quite confusing.
Nitpicking on the name, we do agree that the name is not perfect, but neither is snackbar as used on Android. Maybe something like infobar might be better.
Comment by @torgo Jun 19, 2019 (See Github)
@jackbsteinberg one thing to note: I wanted to mention that the readme on this proposal (the explainer) is really good. I especially like the use of an animated gif to illustrate the concept, and the time you've taken to explain the concept.
Comment by @garygreen Jun 19, 2019 (See Github)
I think the main issues developers will have with the proposal of a <toast>
component:
-
It's very opinionated in terms of how it's presented, styles, etc and some will feel this should really live in userland / libraries.
-
Compared to other tools in the browser like
IntersectionObserver
which are low level tools, this on the face of it seems pretty high level and more of a vanity project to scratch a certain itch.
Rather than having a whole new component, would it be better to instead have a low-level tool where you can position toast-like elements, or tooltips, and leave any opinionated styling or implementation details to developers? The easiest part of building toast-like elements is the UI however the tricky bits are:
- Accessibility
- Stacking multiple elements
- Positioning of elements easily based on text-based descriptor e.g. "bottom-right" "top-left" or around other elements so they remain visible on screen, regardless of scroll position, resizing etc.
Each of these could be solved by low-level tools which would serve multiple purposes not only for toasts but other UI and components, such as tooltips etc. I'm thinking something like:
const position = new StickyElement(document.querySelector('#tooltip'), {
// Calculate best possible position so element is visible on screen
// First try top-center, then bottom-center, etc.
position: ['top-center', 'bottom-center'],
// Calculate relative to the root element, if not supplied will default to document root.
root: document.querySelector('#tooltip-container')
});
position.translate(); // translates / moves the actual element to the best calculated position (one time)
position.track(); // Automatically translate / track whenever browser is resized / scrolled.
position.getRect(); // Returns the `Rect` object for the current best calculated position.
Along with maybe a way of stacking elements?
const stack = new ElementStack({
root: document.querySelector('#scroller')
});
stack.append(positionedElement1);
stack.append(positionedElement2);
stack.prepend(positionedElement3);
Maybe this is already kind of possible with tools that Rect
provides - but I think having a well defined api for this would help with not only toasts but also tooltips, dropdowns / other UI patterns found on the web.
Discussed
Jul 31, 2019 (See Github)
Alice: interested in what you all think
David: still a bunch of namespace discussion in TC39
Hadley: Am I misreading gary greene's responses? Kenneth wrote up a11y concerns. Gary came and says he sees other concerns? Oh... not part of team working on this?
Hadley: So have we seen response from people working on this?
Alice: A little overwhelmed, they have been active in their own repo; our issue thread got pretty noisy.
Kenneth: blink-dev too.
Hadley: what's the best way to get responses to the questions we asked in our issue?
Alice: raises question about our process -- sometimes it's helpful having external people comment on these issues, but sometimes gets very noisy. Becomes difficult for someone to follow the conversation. Doesn't look like we've heard back from them on this issue since we last talked over a month ago.
Alice: a11y issues are going to be difficult to overcome, I think. I'm not convinced it's not a pattern that's inaccessible by design. Do we standardize such a thing, just because we think we can do a better job of a11y than the 50 libraries doing it? Is it a net win, or does it not meet the bar?
Peter: there's the argument that we can get it in front of the right people to get an answer to the a11y argument.
David: common tradeoff with adding features - adding a feature that has negatives for the user increases the use of that feature (negative) but does it in a less bad way than how developers were doing it before (positive)
Peter: push down a week or two?
Alice: would be good to have a longer discussion; a lot to unpack.
Peter: ok, next week then.
Discussed
Aug 14, 2019 (See Github)
Alice: Feels like there's a lot to unpack; not sure where to start.
Alice: For sure there's the namespace issue. There's the naming issue. There's the import thing -- importing a module in std
namespace -- discussed elsewhere on builtin modules -- has that come to the TAG?
Alice: The link text says "builtin module" under proposed API.
Alice: There's pay-for-what-you-use HTML elements, related to builtin modules.
Alice: There's the question (dearest to me) about the process for adding a new HTML element with UI implications. How do we think this should work? What are the requirements?
Alice: Then you get into specifics of design of this specific element and the design pattern.
Dan: Where has the conversation gone on this specific element, since June?
Alice: There's a document -- let me check. They've been working on accessibility. Adding a type
attribute to the element, implies the default style and ARIA role.
Dan: A lot of emotive language in this thread...
Dan: Can we de-link the meta issues you described, e.g., adding UI elements to HTML. We previously had discussion about badging. That's not HTML, but another rather similar (in concept) to what we're talking about here. Something that alerts the user to something that's happening. What is the difference in terms of how easily that discussion seems to be going versus the toast
discussion?
Alice: Also an interesting question.
Dan: Scope of it? For badging we're talking about very specific API. Maybe has a smaller community of practice around it. Once we start talking about HTML it's the entire WHATWG community of practice. All the people who are engaged in it -- all the stakeholders. Group of stakeholders is bigger.
Tess (writing, audio problems): (trying to paraphrase something IIRC dbaron said the last time we talked about std-toast) it makes me nervous that this proposal is built on top of so many other proposals that also haven’t shipped in multiple browsers / been around for a while (JS Standard Library, Import Maps, Builtin Modules, and the open HTML issues about polyfillability & “pay for what you use”ness, etc)
Tess: like, as a general engineering principle, you’re more likely to succeed in adding a new thing if it builds on more stable underlying parts
Alice: ??? we begin addressing the various issues that this brings up?
Dan: We could assign some time at the face-to-face for a toast meta-retrospective. And try to tease out the meta-issues that have come up and discuss each as a separate thing. Could try to time-box that, to try to come to some reasonable conclusion or action on those. Make sense?
Alice: Yes.
Alice: Dan, would you like to leave feedback on issue about identifying subissues, and needing a face-to-face discussion? So that we're not leaving the issue silent.
Dan writes.
Dan: On this issue itself, what do we do?
David: Seems like some of the stuff in this issue depends on the meta-issues.
Dan: Specifically some of the dependencies that Tess brought up.
Dan: Do we need to put this on ice until face-to-face discussion?
David: Maybe worth identifying and opening issues to open before them?
Dan: schedule a breakout to do that?
Alice: I'm happy to go. Also happy to not go if it helps scheduling.
Dan: Australia+California timeslot might make sense.
Tess and David also interested. Maybe Peter, if the time works for him.
Comment by @torgo Aug 14, 2019 (See Github)
We've identified a number of meta-issues here. We discussed in the TAG call today. We agreed to put some time on the agenda for our next face-to-face to discuss these meta-issues and try to come to some actions.
Comment by @dbaron Aug 28, 2019 (See Github)
How is the import mechanism here related to HTML Modules? (HTML Modules is covered by our #334.) Is it the HTML modules import mechanism that's being used here, or not? (If not, then what is, and what defines it?) The examples here don't seem to match the examples there.
Comment by @domenic Aug 29, 2019 (See Github)
They aren't very related, except that they are both types of modules. What's being used here is Web IDL modules.
Comment by @hober Dec 3, 2019 (See Github)
What is the future of this proposal given that Web IDL modules don't seem to be moving forward (heycam/webidl#675)?
Comment by @chrishtr Dec 4, 2019 (See Github)
Similar to issue #384, let's close this review request for now. Thanks for your feedback and comments.
Comment by @kenchris Dec 4, 2019 (See Github)
Closing in response to https://github.com/w3ctag/design-reviews/issues/385#issuecomment-561489329 Thanks for flying TAG.
OpenedJun 12, 2019
こんにちはTAG!
I'm requesting a TAG review of:
Further details:
We'd prefer the TAG provide feedback as (please select one):