-
Notifications
You must be signed in to change notification settings - Fork 214
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
[Popup] Why does it require JavaScript? #437
Comments
Related to this, I suggested something on twitter yesterday that could potentially do something here. pseudocode: <button id="menubutton">open</button>
<popup invoker="menubutton">
<!-- Menu content -->
</popup> Jonathan Neal also suggested the name Not sure really how feasible this would be, but I figured I'd give my 2c, and twitter conversations tend to get buried 😄 Additionally, regarding the JS api, it may be interesting to allow the following API: popup.show({
delegatefocus: true|false,
autofocus: true|false
}); |
I'd like to suggest exposing an Allowing this functionality without JavaScript is an even more eager goal. My concern is not having control over the show/hide transitions via CSS.
If we use a method or attribute to show the popup, we can work around the This may seem like a silly thing to worry about, but users have come to expect this level of customization from dialogs, popups, et al so not enabling it will lead to reluctance in adoption. |
I dont think it's silly at all 🙂 I agree that CSS transitions definitely should be considered. I also think exposing an Consider |
If instead the button had an <button invoke="menu" aria-controls="menu">open</button>
<popup id="menu">
<!-- Menu content -->
</popup> |
Per @stevefaulkner's original question (and ignoring the other comments here addressing CSS and naming), as I read through the explainer I also struggled to understand why script is necessary. I am motivated to not rely on script given how often I see scripts fail to load or run on client engagements, which seems to disproportionately impact users with lower-end devices, old devices, poor connections, disabilities, and locked-down environments. With that framing in mind... This proposal feels closer to a disclosure widget than a dialog. A dialog need not always have a trigger element, but a disclosure must. The Considering that, we already have a native HTML disclosure widget in
In my head I see the following, leaning on the existing <button for="Foo" open>
<popup id="Foo">
Hey there.
</popup> Even though I am abusing |
I believe javascript is necessary and is an important piece of the spec, otherwise it creates a breach to CSS stacking contexts for embedded HTML/CSS. I'll try to explain. There are many times a stacking context is a type of guarantee that a piece of embedded HTML/CSS will not occlude an unrelated part of the DOM. For example, in wikipedia, the text of the wiki (which is embedded HTML/CSS) is not allowed to occlude the navigation elements, and it's enforced by having its parent create a stacking context. By enforcing use of JS, the embedder decides when to open the popup rather than letting the content make that decision. |
I fail to understand how enforcing JavaScript-only triggers on an HTML element is the only way to address its CSS stacking context. I also don't understand your Wikipedia example. Wikipedia is styled content, not raw HTML. Without seeing a sample URL or the HTML structure you have in mind, I am not sure what you are citing (let alone if you mean the desktop or mobile version of Wikipedia). For |
It's not the only way, but it's the most obvious way.
The "Wiki text", for example of a wikipedia article, is styled content - but the embedding page does not let it run its own Javascript and keeps it within its own stacking context, so that it doesn't occlude banners and navigation elements. It's desktop only, here are some materials: Note that a lot of this was discussed in an existing github issue about the subject:
Dedicated triggers are a good alternative to "Javascript only" IMO. My point is about "Javascript only" vs allowing popups to be visible with ambient CSS (without interactions). |
Thank you for the context and links. This proposal should not replicate what Wikipedia has done. Those examples are not exposed in the accessibility APIs. For example, when I navigate the Sloth page (shown as an example in one of those links) and use the virtual cursor of my screen reader, I hear the links but no visible overlays are shown. If I tab my way through each link, then the overlays appear but they are not exposed to my screen reader in any way. I cannot navigate into them. I appreciate you want to use these as an analogue, but these should not be it. Do you have a native HTML analogue that is accessible? I think @smhigley provided a good example of how the stacking context matters when considering a trigger:
https://twitter.com/codingchaos/status/1353514104049209344 Is this what you meant? |
The wikipedia popups have
Yes, something like that. Right now, you have to put it as a child of body in order to break out of overflow/stacking. It's not clear to me whether the popup proposal does the same thing by default, or relies on the new to-be-defined anchor positioning. The proposal hints about that but doesn't say so explicitly. If the new popups don't break existing z-index/overflow, than this reason for requiring JS is moot. |
Thinking more about this, another concern I have is that an HTML-only "invoker" introduces a new pattern we don't currently have in HTML. Even My knee-jerk reaction was "if we do this, can we at least make all existing components work the same way?" But then more I think about it, the less that makes sense. With Popups, as proposed herein, don't have the latter problem because of the "light dismiss" behavior, but must they always be invoked with a click? A tooltip might show on hover/focus, a popover might show on hover, a select-style menu might show on focus. Should the proposed IMO, we should keep this consistent with how dialog works: <popup>Closed initially</popup>
<popup open>Open initially</popup> This lets us display the element in both states with pure HTML, but toggling that state dynamically would, intuitively, require JavaScript. To change existing behavior or introduce new patterns will confuse users and, IMO, is something we should discuss in a separate RFC. |
As a counter argument to this, Also, if the "light dismiss" behavior(/interactivity) is able to be implemented natively, why wouldnt there be a native way to open it also? That seems really off to me. |
Summary is always contained within details, so the trigger is colocated and therefore inferred. Dialogs and popups are independent of their triggers, so that makes it trickier, hence the proposed But you raise a good point. Although I would prefer to handle this with JavaScript, at the end of the day, I'll be happy as long as dialog, popup, and whatever future elements have a consistent API. 😄 |
Agreed, though I think this proposal needs more clarity on that point.
I have worked on projects where the dialog is launched at page load. Time-out alerts, errors, etc. Agreed less common, but still a use case in the wild.
Unless it is its own triggering element, I think I agree? At least with
Same, though there are still cases where no trigger would exist (time-out alerts, error on page load). I think this conversation is valuable to help sort the use cases in my own head, but hopefully others' as well. |
Btw there's an open issue for opening dialogs without scripting: whatwg/html#3567. |
@Malvoz Sadly, the most recent activity by the WHATWG folks on that issue was to propose removing |
Hi everyone, catching up to this weekend's discussion! I mentioned to Steve on Twitter that the intent for the final API is to include some declarative method for popup invocation. We placed that under "areas for future exploration" because there were some interesting questions around scope to think through, but can certainly understand how that might have implied lower priority. Our initial design for this was an attribute that would tie "invoker" to "invokee", and we wanted to get a little bit more crisp about:
We didn't feel we had a solid enough proposal there yet. This discussion is super useful to us in a) illustrating the demand for a declarative approach, and b) gathering any feedback on the above points. So for anyone newly joining this thread, please do upvote if this is important to you! Regarding top-layer management: we do need events in order to rationalize which popup should be displayed on the top layer (in cases where multiple would be displayed based on ancestry), but receiving an event from user interaction with the "invoker" should suffice. |
HTML <button type="popup" popup="my-popup">
Invoker
</button>
<popup id="my-popup">
...
</popup> In this case, Just an observation! 🙂 |
Thanks again everyone for weighing in! The proposal has now been updated for script-less invocation via 369cd27 Closing this thread as the root feedback should be addressed, but please do feel free to file new issues on finer points as needed. :) |
As asked by Steve Faulkners on Twitter: https://twitter.com/stevefaulkner/status/1352326448397348880
It was suggested to create an issue that people can "+1". Didn't see one, so here it is!
I think it's strange for an element to require JS while it could work without. It is strange for a specification in one language to require another. I should be able to build HTML without JS if I wish to.
The text was updated successfully, but these errors were encountered: