Skip to content
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

fix: don't render attribute aria-invalid="false" #20939

Merged
merged 3 commits into from
Oct 14, 2023

Conversation

HowardBraham
Copy link
Contributor

Explanation

The Input and TextField components both include an aria-invalid="false" attribute.

From the aria-invalid documentation:

Note that since the default value for aria-invalid is false, it is not strictly necessary to add the attribute to input.

Before

        <input
          aria-invalid="false"
          autocomplete="off"
          ...
        />

After

        <input
          autocomplete="off"
          ...
        />

@github-actions
Copy link
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

Copy link
Contributor

@georgewrmarshall georgewrmarshall left a comment

Choose a reason for hiding this comment

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

Great catch! I appreciate the focus on accessibility here. I've left a suggestion that aligns with how conditional props are passed in some of our other components e.g

{...(tag === 'button' ? { disabled } : {})}
{...(href && externalLink
? { target: '_blank', rel: 'noopener noreferrer' }
: {})}

Also thought the updates to the snapshot were interesting should the underline props be passed down here I'm not familar with the syntax is. Are they special react or redux props?

Screenshot 2023-09-18 at 1 23 54 PM

ui/components/component-library/input/input.tsx Outdated Show resolved Hide resolved
ui/components/component-library/text-field/text-field.js Outdated Show resolved Hide resolved
@HowardBraham HowardBraham marked this pull request as ready for review September 18, 2023 21:20
@HowardBraham HowardBraham requested a review from a team as a code owner September 18, 2023 21:20
@metamaskbot
Copy link
Collaborator

Builds ready [cb667dc]
Page Load Metrics (1501 ± 43 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint106163132168
domContentLoaded1352172515018943
load1352172515018943
domInteractive1352172515018943
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 15 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@codecov
Copy link

codecov bot commented Sep 18, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (a3a99aa) 68.25% compared to head (865da64) 68.25%.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop   #20939   +/-   ##
========================================
  Coverage    68.25%   68.25%           
========================================
  Files         1006     1006           
  Lines        40184    40186    +2     
  Branches     10742    10744    +2     
========================================
+ Hits         27424    27426    +2     
  Misses       12760    12760           
Files Changed Coverage Δ
ui/components/component-library/input/input.tsx 100.00% <100.00%> (ø)
...ponents/component-library/text-field/text-field.js 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@georgewrmarshall georgewrmarshall left a comment

Choose a reason for hiding this comment

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

Is typescript complaining about this? I'm wondering because when I look at the storybook build in develop the aria-invalid attribute isn't rendering and there doesn't seem to be any snapshot updates?

Screenshot 2023-09-18 at 9 16 57 PM
Screenshot 2023-09-18 at 9 17 19 PM
Screenshot 2023-09-18 at 9 17 40 PM
Screenshot 2023-09-18 at 9 17 56 PM

@plasmacorral plasmacorral added the needs-dev-review PR needs reviews from other engineers (in order to receive required approvals) label Sep 19, 2023
@HowardBraham
Copy link
Contributor Author

@georgewrmarshall haha that's an extremely interesting question about the Storybook!

But the aria-invalid="false" is indeed there in the rendered HTML on the develop branch after #20920 was merged (see screenshot below). And after I rebased this PR on top of develop after #20920, it undoes the snapshot update. (That #20920 snapshot update is what originally made me start working on this.)

I see some evidence that it only updates snapshots if there's a direct code change, and not a change in a 2nd-degree import. Something beyond our current understanding is going on.

image

@metamaskbot
Copy link
Collaborator

Builds ready [865da64]
Page Load Metrics (1657 ± 41 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint116190146199
domContentLoaded1491182016578641
load1492182016578641
domInteractive1491182016578641
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 15 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@HowardBraham
Copy link
Contributor Author

@georgewrmarshall follow-up discovery

  • The Default story is passing error: undefined to the components, which makes it skip the aria-invalid attribute
  • The Error story is passing error: true, which turns up as aria-invalid="true"
  • If you pass error: false, it turns up as aria-invalid="false"

So I think that solves the Storybook mystery. Why it sometimes does not update snapshots, I still don't know.

Copy link
Contributor

@georgewrmarshall georgewrmarshall left a comment

Choose a reason for hiding this comment

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

Right on! Thanks for the thorough investigation and explanation as always 🙏 LGTM!

@HowardBraham
Copy link
Contributor Author

@NidhiKJha @DDDDDanica could one of you review this please? I'd love to close the loop on this PR.

Copy link
Member

@NidhiKJha NidhiKJha left a comment

Choose a reason for hiding this comment

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

LGTM

@HowardBraham HowardBraham merged commit e614498 into develop Oct 14, 2023
9 checks passed
@HowardBraham HowardBraham deleted the fix/aria-invalid-false branch October 14, 2023 07:36
@github-actions github-actions bot locked and limited conversation to collaborators Oct 14, 2023
@github-actions github-actions bot removed the needs-dev-review PR needs reviews from other engineers (in order to receive required approvals) label Oct 14, 2023
@metamaskbot metamaskbot added the release-11.5.0 Issue or pull request that will be included in release 11.5.0 label Oct 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
release-11.5.0 Issue or pull request that will be included in release 11.5.0 team-accounts
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants