Open aleventhal opened 1 month ago
Preemptively adding agenda to this so we can talk about it outside of triage
I don't think I can make this week's meeting. Here is the harmful sentence in the spec: "If an element has global WAI-ARIA states or properties, user agents MUST ignore the none/presentation role and instead expose the element's implicit role."
Basically, when there's a custom element, I want the "MUST ignore" clause to be invalidated, because it's natural for js libraries to use this (Material makes use of this technique). The js copies the ARIA attributes to an element inside of the shadow root. I want the js to then apply role="none" to the custom element, and for the UA to support that.
I spend a lot of time writing components and helping developers fix their components, and personally I would say this is author error.
I would like to advocate for a role for custom components so we can choose to handle those separately, rather than overloading an existing role.
Does this align with https://github.com/WICG/webcomponents/blob/gh-pages/proposals/reference-target-explainer.md wherein an element author has more finite control over the elements receiving the aria values?
Discussed in ARIA working group meeting on Aug 8: https://www.w3.org/2024/08/08-aria-minutes#t05
@spectranaut Can we put this on the agenda again for this week? I'm back from vacation.
@aleventhal how do you see this intersecting with the planned work around https://github.com/WICG/webcomponents/blob/gh-pages/proposals/reference-target-explainer.md We're getting close to a testable implementation via https://chromium-review.googlesource.com/c/chromium/src/+/5615615 and https://chromium-review.googlesource.com/c/chromium/src/+/5739315 thanks to @behowell and @dandclark
@Westbrook Unless the author set role=none on the custom element, it wouldn't have any effect. I don't see the author doing that and also using an element relation to point inside of the shadow root via reference target, because if the custom element is copying the ARIA into elements inside of the shadow root, then those relations already don't need to cross-shadow root solution, as they are both originating and targeting elements inside of the shadow root.
In that case, I'm pretty sure that I'm misunderstanding your use case. Would you be able to share a more concrete example?
Example:
<my-weird-checkbox aria-label="I like cats" aria-description="Think deeply about your relationship with cats">
...
In a constuctor or init code:
<div role=checkbox>
this.role = 'none'; // Remove the original custom element from the a11y tree.
If the browser follows current rules, it must ignore the role=none and keep the custom element in the tree, thus causing 2 nodes to have the same label and description. We had that rule because nobody could think of a reason that you would need global ARIA attributes and role=none on the same element. I'd like to alter the rule now that we see a reason that authors do it.
In that case, is it better for the author for the browser to ignore the combination of role="none" aria-label="..."
on the assumption that they pass the value down for themselves or to discuss expanding Reference Target to manage absolute attributes as well, so that the author wouldn't need to manually pass those values?
I'm no browser implementor, but it would seem that whatever allows the label in this example to be passed through:
<label for="x-checkbox">I'm a checkbox</label>
<x-checkbox id="x-checkbox">
<template
shadowrootmode="open"
shadowrootreferencetarget="real-input"
>
<input type="checkbox" id="real-input">
</template>
</x-checkbox>
Could/should pass through the same when the code was:
<x-checkbox aria-label="I'm a checkbox">
<template
shadowrootmode="open"
shadowrootreferencetarget="real-input"
>
<input type="checkbox" id="real-input">
</template>
</x-checkbox>
I'm not sure — we can study that. Is there any reason that we can't do what I propose as a solution for existing content that we have now? It wouldn't seem to invalidate other future solutions.
Put another way, we only didn't allow role="none" to ablate nodes from the tree when they had other ARIA properties, because we couldn't imagine a reason. Now that we can imagine a reason, this rule is doing harm and I'd like to remove the rule.
This also seems misleading if I explicitly set a role on the host element and the browser doesn't respect that.
It would be nice to allow the user to apply these attributes and allow us to map them to the appropriate internal shadow DOM elements. We have many teams that don't understand custom elements, so, rather than use our APIs, add their own aria
attributes. Although this isn't a true replacement for the "reference targeting" that @Westbrook was referring to, it would be a nice safety net to provide a good user experience.
Discussed in today's ARIA working group meeting: https://www.w3.org/2024/08/15-aria-minutes.html#t05
In that aria-label
and aria-description
, et al. are not reference attributes, they won't be applied via Reference Target in the currently discussed form. If role="none"
, I don't see much harm in my experience in removing an element from the AT and allowing it's custom implementation do to what it will with the values applied to them. There's certainly some author knowledge required around aria-label
reflected to ariaLabel
, etc. but if you're already doing the work to role="none"
hopefully you'll be covering all of your bases for the rest of the functionality.
However, I do think that there is no great difference between an element getting labelled with aria-label
and getting labelled with aria-labelledby
and think that this should be handled in future iterations of Reference Target. To start that conversation, I've opened https://github.com/WICG/webcomponents/issues/1068, which posits an even larger expansion of Reference Target to start, so that when it gets whittled down a bit we're likely to still get coverage for common sense items like those referenced in this issue.
Is role="custom" (applied with some formal grammar mapping rules to avoid misuse) completely off the negotiation table?
I remember there was an old idea in the ARIA group (at 1.0 times) to allow custom roles (or role customization) using e.g. JSON notation. But this caused a can-of-worms discussion and the idea was abandoned.
In this sense, for a checkbox with additional properties authors could write
<div role="custom checkbox">
with attached JS fetch handler for JSON data that contains ARIA and custom attribute value pairs. Of course screen readers must be prepped to support this.
@aleventhal to summarise the proposal (unless I am over simplifying). We would add to the last bullet of the presentational roles conflict resolution section:
to become something like
Yes James, that sounds good to me. Do we want to add some non-normative text explaining why the exception exists?
On Wed, Aug 21, 2024 at 3:18 PM James Nurthen @.***> wrote:
@aleventhal https://github.com/aleventhal to summarise the proposal. We would add to the last bullet of the presentational roles conflict resolution section:
- If an element has global https://w3c.github.io/aria/#dfn-global WAI-ARIA states or properties, user agents MUST ignore the none https://w3c.github.io/aria/#none/presentation https://w3c.github.io/aria/#presentation role and instead expose the element's implicit role. However, if an element has only non-global, role-specific WAI-ARIA states or properties, the element MUST NOT be exposed unless the presentational role is inherited and an explicit non-presentational role is applied.
to become something like
- If an element has global https://w3c.github.io/aria/#dfn-global WAI-ARIA states or properties, user agents MUST ignore the none https://w3c.github.io/aria/#none/presentation https://w3c.github.io/aria/#presentation role and instead expose the element's implicit role unless the element is a custom element and has an explicit role=none/presentation. However, if an element has only non-global, role-specific WAI-ARIA states or properties, the element MUST NOT be exposed unless the presentational role is inherited and an explicit non-presentational role is applied.
— Reply to this email directly, view it on GitHub https://github.com/w3c/aria/issues/2303#issuecomment-2302839898, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAKQAZQNRIDXBV2I6YKFZZ3ZSTRYNAVCNFSM6AAAAABL5J4MXKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMBSHAZTSOBZHA . You are receiving this because you were mentioned.Message ID: @.***>
Yes James, that sounds good to me. Do we want to add some non-normative text explaining why the exception exists?
I think a note for this would be a good addition. I just want to clarify what we are discussing as a possibility. We'd obviously want to make sure that the other browser vendors are on board too.
Describe your concern
It's natural to provide ARIA properties on a custom element and then have the custom element implementation copy that property to a descendant. For example, aria-label, aria-description or aria-placeholder could be provided by the author on the custom element. The custom element would then copy the ARIA properties to the actual input element in its subtree, and it could then place role="none" on the custom element to avoid 1) Having an extra element in the a11y tree with duplicate properties and 2) Using a name on the custom element which likely has a generic role -- name on generic is prohibited.
Currently the role="none" (or role="presentation") on the custom element is ignored because we are afraid of losing the semantics. However, it seems like a reasonable use case to me. I don't think custom elements should get their role="none" markup ignored when used with aria-foo properties. It should still ignore role="none" if it has a tabindex.
Link to the version of the specification or documentation you were looking at at.
https://w3c.github.io/aria
Link to documentation:
https://w3c.github.io/aria/#conflict_resolution_presentation_none
Does the issue exists in the editors draft (the editors draft is the most recent draft of the specification)?
Yes