-
-
Notifications
You must be signed in to change notification settings - Fork 408
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Ember.component support for aria-label, aria-labelledby, and aria-describedby #242
Conversation
I like the idea here. I'm also thinking about a generic solution that let's you assign any attribute. One idea is to use a subexpression as a final positional argument: {{my-component (html-attributes aria-labelledby="label-name")}} There's already some precedence with link-to and the query-params subexpression. |
While making it easier to improve accessibility by default is a noble goal, I feel like this is the wrong approach. Just as I feel like Introducing default attribute bindings for every component incurs a (arguably small) performance hit and more importantly increases API surface area. Also, where do you draw the line of which attributes should be bound by default and which not? As @mmun already suggested, I would rather improve the primitives for binding attributes to make it less of a hassle. Depending on the use case, there are two scenarios: You either want a component to declare its HTML attributes itself (maybe in dependence of data attrs that were passed into the component) or you want to pass HTML attributes when invoking the component. AFAIK Glimmer components will elegantly solve the latter by making a distinction between data attrs and HTML attributes. (Correct me, if I'm wrong here. I can't find the RFC / docs.) <my-component aria-role="button" @user=alice> And ember-decorators/ember-decorators#133 would give you a really nice idiomatic way of defining attribute bindings. No more import Component from '@ember/component';
import { computed } from 'ember-decorators/object';
import { attribute } from 'ember-decorators/component';
export default class extends Component {
@attribute('aria-label') label = 'foo';
// or even as a computed property:
@attribute('aria-label')
@computed('foo', 'bar')
label(foo, bar) {
return `${foo}-${bar}`;
}
} In the meantime, while this is all being fleshed out, you could define default attribute bindings for your own components: // app/components/accessible-component.js
import Component from '@ember/component';
export default Component.extend({
attributBindings: [
'ariaLabel:aria-label',
'ariaLabelledBy:aria-labelledby',
'ariaDescribedBy:aria-describedby'
]
});
// app/components/foo-component.js
import AccessibleComponent from 'my-app/components/accessible-component';
export default AccessibleComponent.extend({
ariaLabel: 'something'
}); |
I'd just like to add to @buschtoens reply that using |
@miguelcobain I was gonna suggest the same, but was unsure where to actually put the code that reopens the Where would you reopen the class? In the |
@buschtoens I see most people (including myself) reopening in initializers. At least in addons, an initializer seems to be the only way to go. |
Regarding reopening I would tend to put it in a vendor file, and |
This is correct. The docs are on the glimmerjs.com website, but expect to see an RFC here before we pull glimmer-style component invocation into Ember. |
Two items to consider:
Reading the other comments has me curious: what's the "bigger-yet-still-negligible" perf hit, having an unused property or reopening a component? |
Can you explain your position on this? Currently in ember each time I want to use aria attributes I have to set up the attribute bindings so ember components can render those aria attributes. Writing an initializer to extend ember is a hack imo. It's a hack to fill a gap in the framework and none of the greater community benefits from it. I'm 100% on board with adding at least these aria attributes. I would expect to write the following and not have to do any extra work to make it work: {{fake-button ariaLabel="Click me!" ariaRole="button"}} What ember should render:
I want to understand your pushback. I do agree current ember components make it hard to add any attributes. This is where accessibility can drive a better API for everyone (not just for a11y). But I feel strongly that this is something Ember needs to do right, out of the box, in order to complete the "SDK of the web" dream. To sum this up: single page apps have a ton of accessibility problems. Accessibility without a framework is hard enough, but it becomes even harder when you have to fill in the gaps of the framework to do it. It makes the barrier of entry even higher, which discourages devs from even trying. |
To me that reads like the "Alternatives: do nothing" approach I see often with RFCs. 😅 I was trying to address that with my remarks on inheriting from a common From your POV, is there any disadvantage to baking this right into the framework?
I have zero statistics or research to back this up, but from a purely anecdotal standpoint I would argue that the majority of Ember.js users cares way too little about a11y. Especially as a newcomer to web development or Ember.js chances are that you've never heard of They might argue that an attribute like
The property
All in all, using default baked in bindings is probably a bit faster compared to So my main points of critique are:
|
The problem you are referring to (passing plain HTML attributes is hard) has a broader scope and is not limited to We should rather improve the primitives, which Glimmer Components try to do. {{fake-button aria-label="Click me!" role="button" @someDataAttr="foo"}}
You can use the same argument for making |
Aria attributes are a web standard like any other, and most importantly Ember as an ecosystem is about good defaults for letting you use web standards to make great experiences for your users. Making accessibility hard doesn't seem like a good default. While that problem in particular is hard, it's also being addressed with glimmer components. I don't think it's worth blocking this feature that people have needed and requested for as long as I've been doing Ember. When an accessibility problem comes up, a common answer is to adjust other attributes like
Changes in Glimmer take a long time to go through the RFC cycle and then be implemented in Glimmer/Ember. If the primitive is non-accessible to Ember developers now or in the immediate future, what should people do? Monkey-patch the framework in ways that it could break when glimmer components finally land? I think we'll see curly components exist for a long while after Glimmer components are in Ember core. This use case is solvable in both curly components and glimmer; I don't see why users should have to pick one.
I think that's more of a strawman. |
The reason people don't use |
I think this is a problem with the web development community in general. If the goal is to engage developers on accessibility, locking them out of accessibility features doesn't seem like a way to empower developers to care more. Instead, they'll just be frustrated and not try to continue to try and learn. It takes a certain amount of googling to even find the answer to attribute bindings, let alone in the context of accessibility.
I don't think Ember has really ever embraced monkey patching the core primitives, even in the earlier days where we used to do it all the time 😛 . For the 3 attributes provided, this might not even be that big of a change to the default list of attribute bindings. I don't think we're doing anyone a huge favor by leaving them out. |
I personally really like @mmun's suggestion to make it convenient to do attribute bindings in curly components using a helper here: #242 (comment). Like with aria, I think it's a matter of legacy reasons why the initial set of default attribute bindings was limited/not generated at runtime. |
Agreed. I quite like @mmun's proposal also. It elegantly solves both the specific issue this RFC is trying to address and the general issue of "there are lots of attributes that other component authors haven't thought of". |
Please don't get me wrong. I'm not saying it isn't a standard or that we should make accessibility intentionally or inadvertently hard. Quite the contrary actually. 😄
I only wanted to point out that this could set a precedent for letting "non-primitive" features creep into the framework API and users could bring this up when asking for more default attribute bindings.
Valid point. Since Glimmer components are a distant future and performance is likely no problem, feature creep and increased API surface area are my only concerns. They have been addressed and if the core team thinks that the benefits outweigh, I am of course on board with that decision. Ideally we would converge on a primitive that would work in the near future, like what @mmun suggested. |
While I like @mmun’s recommendation for a new helper I think it deserves a separate RFC and IMO would be a great addition. That said, I agree a lot with the reasoning that Ember should put A11y at the forefront of features and basic support around the most common aria roles shouldn’t be “oh use the mixin or helper for non-standard HTML attributes”.
This RFC begins to push that every component should start to be an “AccessibleComponent” or at least a “SlightlyMoreAccessibleComponent”.
While I think that a lot of jr devs may not be familiar, not supporting aria is actually making that worse since it’s an extra hurdle for them to go through. Since a growing number of devs coming to Ember from other ecosystems value presentational/template only components I think it’s valuable that we don’t require them to suddenly modify/create the JS for binding aria values. |
It's appropriate for Ember.component to have the It's perhaps not the wisest idea to give false equivalency to "all" Ember developers, or even "most" Ember developers, just by looking at who is in Slack or comments on Github. Ember is for building "ambitious applications," right? Consider all of the enterprise developers who use Ember, who are not permitted to use Slack on their computers at work, or not permitted to use Github for their code. My perspective is one of an enterprise developer. There are a lot of us, and we do have a legal requirement in the US for accessibility, and it effects our jobs every day. We contribute to open source in other ways, some of us during nights and weekends. The U.S. isn't the only country that requires digital accessibility for specific "places of public accommodation." Similar laws exist around the world - the places I know of off the top of my head are the UK, Sweden, Japan, and Spain. I've spent the last year of my life, focusing on accessibility as a singular focus. I've read through every page of the ARIA spec, looking at all of the methods for success and failure, and trying to figure out how to make it simple enough so other developers could reasonably care, but still leaving it complex enough so it's not too boring. I'll be honest, I haven't found that balance quite yet. But since 1 in 10 users has some sort of barrier that effects their relationship with technology, every bit helps. The idea that @mmun presented is intriguing. I like it because it thinks bigger than just what I was asking for. However, when considering what to ask for in this RFC, I thought about the things I needed and the things I wanted, then applied the constraints of "keep it specific." It's more likely to be adopted in the enterprise world if it's specific, because specificity provides guidance. |
I strongly agree with this statement. However I've been using Ember for 4+ years and I didn't know there was an |
Sorry to be "that jerk", but I actually disagree fairly strongly here. It is (and as far as I can tell always has been) Ember's job as a framework to provide general solutions to common problems. The somewhat narrow and specific problem that this RFC is attempting to address is a few ARIA attributes, but from my perspective that is only a very very tiny drop in the bucket. We need to write idiomatic standards compliant HTML which means that we will need MANY attributes all based on how we are actually using an underlying component. Solving the very specific problem of these 3 attributes, doesn't help us at all with solving the others (and adds even more to the "Ember is too magical" camp). Basically, I'm saying that I think the answer to this question:
Should not involve memorizing a mapping of attribute to property names. Every rule we add to this mental mapping, makes it less likely that any one single rule will be remembered ("brain buffer overflow" 😝). I think we should absolutely try to push forward on @mmun's suggestion. |
From @mmun in #242 (comment):
Totally agreed! |
I don't think you're being a jerk at all. I think we agree on the heart of the issue. I could have better explained my position by giving an analogy- providing a machine-readable name is like filling up the bucket a third of the way. It's not the only thing you have to do, but it's a huge step in the right direction. I was asking for the base model car, @mmun approach gives me the car + all the luxury features for free. More than I was targeting, so if it can be implemented and makes more sense to implement, I'm all for that. |
@rwjblue I think a good spot would be let's grab some of the A11Y specific engineers from the bigger Ember teams and have them weigh in to get this RFC to the most vital accessibility attributes (maybe that discussion boils down to I think let's start as a separate thread/RFC the I think we've seen three different things that are three different problems here:
|
Pinging @krivaten :) |
Hey folks. @rwjblue and I spiked out an addon for #242 (comment). Check out https://github.com/mmun/ember-component-attributes. If anyone is up for writing a new RFC based on this addon I'd appreciate it :) |
@crodriguez1a I'm not totally sold on it either. I went with |
Closing this.
|
Requesting specific consideration for the three ARIA attributes that I am putting in to every component I build. It would help on multiple levels to have this supported by default in Ember.component, like ariaRole.
(inspiration for this RFC also comes from this issue: emberjs/ember.js#13224 - but I did not see a resulting RFC)
Rendered