Skip to content

Conversation

@mahoneycm
Copy link
Contributor

@mahoneycm mahoneycm commented Feb 2, 2023

Summary

This PR takes a look at existing disabled classes and attempts to replace them by just using the disabled and aria-disabled attributes in their place.

In it's current state, USWDS contains two --disabled classes and one placeholder.

usa-button--disabled class

There was an existing usa-button--disabled class that acquired all of the same style definitions as button classes that had the disabled or aria-disabled attributes. The classes themselves were not used on our storybook or USWDS Site.

There is a note on site that states to not use the class unless for testing or debugging. It might be best to simply remove the class as well as the note on site.

Use the browser-native disabled attribute for any disabled button. Don’t use usa-button--disabled, which is intended only for debugging and prototyping. 1

usa-file-input--disabled class

File input uses a class to apply disabled styling to the child elements of the target <div>. Generally, this is acceptable behavior and helps to assign styles since the <div> element does not receive the disabled attribute.

After discussion, we have decided to allow disabled classes that style elements that:

  1. Do not receive the disabled attribute
  2. Are dynamically placed

This will allow us to correctly style elements as disabled without putting the burden on the user.

usa-date-picker--disabled placeholder

Date picker uses a disabled placeholder but applies these settings to elements with the disabled or aria-disabled attributes, so we can safely ignore.

Breaking change

This is potentially a breaking change

While we advise against using the usa-button--disabled class, this would break markdown for devs who have implemented it

Related issue

Closes #5116

Preview links

Button →
File Input (disabled) →

Problem statement

Rather than relying on specific state classes to target disabled components, we should instead target these elements using the disabled or aria-disabled attributes.

Solution

  1. Remove unused and redundant disabled button classes
  2. Ensure disabled classes are dynamically set using the related form element as to not put the need on the user.

Testing and review

  1. Review the current state of disabled buttons
  2. Confirm no visual discrepancies
  3. Tests File Input to make sure dynamic creation works as expected

Before opening this PR, make sure you’ve done whichever of these applies to you:

  • Confirm that this code follows the 18F Front End Coding Style Guide and Accessibility Guide.
  • Run git pull origin [base branch] to pull in the most recent updates from your base and check for merge conflicts. (Often, the base branch is develop).
  • Run npm run prettier:scss to format any Sass updates.
  • Run npm test and confirm that all tests pass.

Footnotes

  1. https://designsystem.digital.gov/components/button/#:~:text=Use%20the%20browser%2Dnative%20disabled%20attribute%20for%20any%20disabled%20button.%20Don%E2%80%99t%20use%20usa%2Dbutton%2D%2Ddisabled%2C%20which%20is%20intended%20only%20for%20debugging%20and%20prototyping.

- File-input styles now use already included aria-disabled attribute as the selector for disabled styles.
- Unit test updated to match this new pattern
@mahoneycm mahoneycm requested review from amyleadem and mejiaj February 2, 2023 20:18
Copy link
Contributor

@amyleadem amyleadem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good so far. I added some comments for a couple items I saw.

I also wanted to flag that this work might conflict with the input prefix/suffix disabled fix: PR #5004. We should look into removing the --disabled classes from that fix as well.

Let me know if you have questions.

Tests performed:

  • Confirm that all disabled-specific classes have been removed (wherever possible)
  • Confirm that both aria-disabled and disabled trigger disabled styles
    • Buttons
    • File input

@mahoneycm mahoneycm requested a review from amyleadem February 7, 2023 20:57
@mahoneycm
Copy link
Contributor Author

@amyleadem @mejiaj Restored file-input's dynamically set disabled glass based on our discussion yesterday and updated the PR description to reflect our decision to allow dynamically set disabled classes on divs that do not receive the disabled attributes moving forward.

Copy link
Contributor

@amyleadem amyleadem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! Only thing I would consider is flagging this as a potentially breaking change in the PR description. We do advise against using the disabled button classes in our guidance, but it might be worth flagging just in case.

I performed the following tests:

  • Confirm that all instances of disabled classes have been accounted for in this PR
  • Confirm that all remaining instances of disabled classes are dynamically added (no additional burden on user)
  • Confirm that none of the button variants rely on a disabled class
  • Confirm that both aria-disabled and disabled show disabled button styles
  • npm run test completes without error

@mahoneycm
Copy link
Contributor Author

@mejiaj Bumping for review!

@mejiaj mejiaj added this to the uswds 3.5.0 milestone Mar 16, 2023
@mejiaj mejiaj requested a review from thisisdano March 20, 2023 17:27
@mejiaj
Copy link
Contributor

mejiaj commented Mar 28, 2023

@mahoneycm I've reviewed and approved. Please request re-review (if needed) via the the arrow on the reviewers panel.

@mahoneycm
Copy link
Contributor Author

Work implemented in #5063

@mahoneycm mahoneycm closed this Mar 29, 2023
@mejiaj
Copy link
Contributor

mejiaj commented Jun 8, 2023

Removing this issue from 3.5.0 milestone to avoid confusion. Work was done in #5063.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

USWDS - Disabled styles: Phase out disabled classes

4 participants