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: update json export to properly parse tagName elements #6132

Merged
merged 1 commit into from
Oct 14, 2022

Conversation

madalynrose
Copy link
Contributor

@madalynrose madalynrose commented Oct 14, 2022

Details

Our Assessment JSON export mechanism surfaces the rule id and description for each requirement. The description originates as JSX and then gets converted into a string. This works fine for the majority of our requirements, where the JSX props contain children that mostly include innerText. This is not the case for several requirements that include Markup.Tag tags.

For example, the Semantics Assessment's "Header Attribute" Requirement includes two Markup.Tag tags for td and th that do not have children.

const headersAttributeDescription: JSX.Element = (
    <span>
        The <Markup.CodeTerm>headers</Markup.CodeTerm> attribute of a <Markup.Tag tagName="td" />{' '}
        element must reference the correct <Markup.Tag tagName="th" /> element(s).
    </span>
);

When our JSON exporter encounters tags without children, it appends "undefined" to the string:

{
   "requirementKey": "headersAttribute",
   "requirementDescription": "The headers attribute of a undefined element must reference the correct undefined element(s)"
 } 

This fix adapts our description builder to look for the tagName property if children does not exist.

{
   "requirementKey": "headersAttribute",
   "requirementDescription": "The headers attribute of a td element must reference the correct th element(s)"
}
Motivation

Addresses issue #6122

Pull request checklist

  • Addresses an existing issue: english a/an in error text #6122
  • Ran yarn null:autoadd
  • Ran yarn fastpass
  • Added/updated relevant unit test(s) (and ran yarn test)
  • Verified code coverage for the changes made. Check coverage report at: <rootDir>/test-results/unit/coverage
  • PR title AND final merge commit title both start with a semantic tag (fix:, chore:, feat(feature-name):, refactor:). See CONTRIBUTING.md.
  • [n/a] (UI changes only) Added screenshots/GIFs to description above
  • [n/a] (UI changes only) Verified usability with NVDA/JAWS

@madalynrose madalynrose requested a review from a team as a code owner October 14, 2022 14:55
Copy link
Contributor

@katydecorah katydecorah left a comment

Choose a reason for hiding this comment

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

Nice fix, @madalynrose!

@madalynrose madalynrose merged commit eb2c1f4 into microsoft:main Oct 14, 2022
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.

2 participants