Problem/Motivation
There's research to prove that using disabled button elements is bad for usability and accessibility. For example, Disabled buttons suck provides a comprehensive explanation of why disabled buttons shouldn't be used, and what should be used to replace them.
The core problem is that when a button is disabled, the user won't know why it is disabled. Preventing actions could be still done by either not showing the button at all, or by showing the button as active, and after a user clicks a "disabled" button, the system would show an error including an explanation of why the action couldn't be triggered.
At the moment, we support the disabled state by specifically adding classes to buttons based on disabled state. We also provide styles for the disabled state in our themes.
Proposed resolution
Deprecate disabled state for buttons in Drupal 8.8.0 and explain that all explicit support for them will be removed in Drupal 9. Since we don't want to be on the way of people, people should be still allowed to pass in the attribute buttons but it wouldn't be supported by Drupal themes out of the box. This way people would be still able to achieve the same end result in custom projects, but we discourage contrib projects and core from using this pattern.
Comments
Comment #2
andrewmacpherson commentedI'm very skeptical of this. Whatever the problems with disabled buttons (especially styling), they are part of the HTML rec, and I don't think we can ignore that. Developers WILL create disabled buttons in their custom modules, and if core themes don't support this, users will have no way to know that the button is disabled, and that will be the fault of our core themes.
There's an interesting response to the axesslab article here - https://medium.com/@DanielKoster/disabled-buttons-dont-have-to-suck-6dcd...
Comment #3
andrewmacpherson commentedBoth these suggestions can work, but they depend on the context of the application. These might be interesting to create as separate FAPI element types, with their attached behaviours.
The problem with this is that it segregates users even more. Sighted users without assistive will see a button, but not know that it is disabled. Meanwhile the disabled attribute will be programatically conveyed to assistive tech, so some users will indeed know that it's a disabled button.
Browsers have default styles for disabled buttons. If our core themes override button styles, and don't provide a style for disabled buttons, then the core theme is actually less accessible/usable/informative than the browser style.
Comment #4
lauriiiThe problem that I tried to convey is that from our documentation, and API point of view, there's no risk at all in marking buttons disabled. There's explicit support for that. Also because we are lacking metadata, it's not possible to fix this in theme level.
AFAIK, there aren't any excuses for marking button disabled without providing an explanation of why the button has been disabled. If an explanation isn't provided, there's always room a chance that some users get confused. Given that, maybe a better solution would be to provide an opinionated way to mark buttons as disabled that would require providing a message on why the action cannot be run. This could be implemented differently by each theme.
Often times buttons are disabled for no good reason. Requiring a message forces developers to think about why the button was disabled and could lead to them finding better alternative solutions. For example, what Drupal core does if user is lacking permissions for triggering an action, the button is simply not shown for the user.
Comment #13
mgiffordJust adding some more research to this:
Comment #15
mgiffordIt's been 3 years, so here are some updated references (via AI):
Comment #16
kentr commentedTo me, this goes beyond accessibility b/c it affects every user.
I'm curious about the usability team's opinion. Setting to Needs review b/c I think they use that tag to find issues for UX review.