-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Add commandfor & command attributes to HTMLButtonElement #9841
base: main
Are you sure you want to change the base?
Conversation
45e4032
to
9579336
Compare
I realize this is also in the steps for getting the popover target element, but in both cases I'm wondering why its specified to return null if the node is in the disable state? Doing so, at least with
that state gets removed. That's unexpected, to have that state removed based on whether the button is disabled or not. And for invokertarget - if it is really is going to do more than just show/hide content - there are a lot of other states that should still be exposed, regarless of if the element is in the disabled state or not. edit: I can file a bug for disabled / popovertarget if necessary - i just wanted to get insight on this first, before I went and made that issue. cc @mfreed7 |
This comment was marked as outdated.
This comment was marked as outdated.
7f0f9ea
to
834a8b1
Compare
See related spec PR whatwg/html#9841
Fwiw HTML requires a positive standards position or for chrome LGTMs on an intent to ship to be considered supportive. Saying that Mozilla have marked their position as positive so that's 1 implementor interested. I do wonder how this requirement works for a feature such as this which will require multiple PRs to add to the spec? |
I'm confused why this feature is being done as multiple PRs; it makes review a good deal harder. |
If it makes it easier to review I’m happy to put more into one PR. I figured it would be worthwhile splitting it into the core vs each elements behaviour as I imagine there will be more to discuss with each elements behaviour. |
Well, it'd make it easier for me, but I haven't signed up to review yet, so no need to make any changes until we get some more opinions :) Edited to add: the reason it makes it more difficult is that I don't think we want to accept the feature piecemeal. |
As per openui/open-ui#900 (comment) this'll need updating to only fire the event when the action is custom (has a hypen) or is recognised and valid (correct action name on correct element). TLDR is that this will allow us to add default actions in future without conflicting with user land code. |
In openui/open-ui#952 (comment) we resolved that "Invokers v1 will be popover and dialog invoking." This should help keep this initial PR as small as possible while also avoid the issue of reviewing stuff piecemeal. So #9875 can be merged into this along with dialog related changes. |
Chromium is explicitly supportive of this proposal, so I believe it has two implementer support (including Mozilla). Is this PR in a state that it can get a review? I'm happy to do so, if it'd help. |
I'd be happy to get reviews, I think this is in a good position for that. |
Done - I added a first set of comments. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments apply to the next line instead due to a second unforeseen force push.
data-x="attr-button-command-unknown">unknown</dfn> state.</p> | ||
|
||
<p>A <dfn>valid custom command</dfn> is a string whose first two code points are the U+002D | ||
HYPHEN-MINUS character.</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought we landed on a single hyphen here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought it was double hyphen, that's certainly how I've been steering the prototype. I'm happy to move to single hyphen if that's preferred.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I remember this being discussed, I just don't remember what we decided on. I guess double is okay, but it seems rather weird as we're not bound by the same limitations as CSS for syntax.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While not bound by CSS limitations, would it not still be better to be consistent with CSS custom properties?
I don't recall using single hyphen prefixes anywhere else in web development apart from vendor-specific CSS properties (i.e. -webkit-...
).
Given custom commands are author-specific, not vendor-specific, it would make sense to me as a developer to be aligned with custom properties in terms of using a double hyphen prefix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe? But why require people to type --play-piano
when -play-piano
provides all we need? Anyway, I don't feel strongly and we can always make it less strict later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We discussed in WHATNOT and there was ambivalence between single- and double-dash. We discussed in OpenUI and there was strong developer preference for consistency with CSS, with a double-dash.
This was incorrect
See related spec PR whatwg/html#9841
@annevk I re-worked the submit button piece a bit in d897bd8, as we discussed in the matrix channel. This commit removes the dl/dds that existed within the activation steps, instead opting for some ifs. Perhaps more impactful, however, is that it states that a button is only a "submit button" (concept) if it is implicitly or explicitly in the submit state but without |
@keithamus I don't see how that fixes the |
@annevk I tried to expand the |
|
@@ -53374,6 +53377,8 @@ You cannot submit this form when the field is incorrect.</samp></pre> | |||
interface <dfn interface>HTMLButtonElement</dfn> : <span>HTMLElement</span> { | |||
[<span>HTMLConstructor</span>] constructor(); | |||
|
|||
[<span>CEReactions</span>] attribute DOMString? <span data-x="dom-button-command">command</span>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be DOMString
now, right? Without question mark.
@@ -53455,42 +53518,170 @@ interface <dfn interface>HTMLButtonElement</dfn> : <span>HTMLElement</span> { | |||
<li><p>If <var>element</var>'s <span>node document</span> is not <span>fully active</span>, then | |||
return.</p></li> | |||
|
|||
<li><p>If <var>element</var> has a <span>form owner</span> and is a <span | |||
data-x="concept-submit-button">submit button</span>, then <span | |||
data-x="concept-form-submit">Submit</span> <var>element</var>'s <span>form owner</span> from |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Submit here should be lowercase. It's an algorithm, not a state. Right?
<li><p>If <var>type</var> is in the <span | ||
data-x="attr-button-type-submit-state">Submit</span> state, and <span>this</span> is a <span | ||
data-x="concept-submit-button">submit button</span>, return the string | ||
"<code data-x="">submit</code>".</p></li> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for a comma before and as there's only two conditions.
"then return". But also, isn't the first condition redundant with the second? Maybe this should be the first step, then a check if type attribute is in the reset state, and then returning button.
This adds the
commandfor
&command
attributes and a "command" event using theCommandEvent
interface.Button activation checks if the button has a "commandfor" target and if so performs invoker command behaviour depending on
command
and the target element.(See WHATWG Working Mode: Changes for more details.)
/dom.html ( diff )
/form-elements.html ( diff )
/index.html ( diff )
/indices.html ( diff )
/interaction.html ( diff )
/interactive-elements.html ( diff )
/webappapis.html ( diff )