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

[Design2-108] DSCO - Add Aria/AriaDescribedBy attributes to components where needed #58469

Merged
merged 5 commits into from May 14, 2024

Conversation

levadadenys
Copy link
Collaborator

@levadadenys levadadenys commented May 8, 2024

[Design2-108] DSCO - Add Aria/AriaDescribedBy attributes to components where needed

  • added helpers, add getAriaPropsFromProps helper function
  • added aria- attributes support for Button components
  • added aria- attributes support for ...Dropdown components
  • add aria- attributes support for FontAwesomeV6Icon component

Links

Testing story

Deployment strategy

Follow-up work

Privacy

Security

Caching

PR Checklist:

  • Tests provide adequate coverage
  • Privacy and Security impacts have been assessed
  • Code is well-commented
  • New features are translatable or updates will not break translations
  • Relevant documentation has been added or updated
  • User impact is well-understood and desirable
  • Pull Request is labeled appropriately
  • Follow-up work items (including potential tech debt) are tracked and linked

@levadadenys levadadenys changed the title [WIP] [Design2-108] DSCO - Add Aria/AriaDescribedBy attributes to components where needed [Design2-108] DSCO - Add Aria/AriaDescribedBy attributes to components where needed May 9, 2024
@levadadenys levadadenys marked this pull request as ready for review May 9, 2024 16:34
@levadadenys levadadenys requested review from sanchitmalhotra126 and a team May 9, 2024 16:36
Comment on lines +15 to +20
const ariaProps: {[key: string]: PrimitiveValue} = {};
Object.keys(props).forEach(key => {
if (key.startsWith('aria-')) {
ariaProps[key] = props[key];
}
});
Copy link
Contributor

Choose a reason for hiding this comment

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

this is fine and doesn't need to be changed, but I think it reads a little nicer with a fromEntries and a filter.

const ariaProps: {[key: string]: PrimitiveValue} = Object.fromEntries(
  Object.entries(props).filter(([key]) => key.startsWith('aria-'))
)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Agree it reads better in your suggestion. Though, I got interested and compared the perfomance of both implementation and the current one turned out to be faster.
The more props there'll be in an array - the bigger gap would be it was 12% average faster when there were ~15 props and it turned out to be 27% average faster when there were. ~25+ props pased. Giving that this function will be used a lot and the number of props passed here is unknown (it's possible there'll be 10 and more props for one component) I suggest we stick with current version. Reason of execution time difference smaller is a number of operations executed in the current version.

Copy link
Contributor

@thomasoniii thomasoniii left a comment

Choose a reason for hiding this comment

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

minor non-blocking syntactic sugar suggestion, but otherwise lgtm 🚀

@levadadenys levadadenys merged commit ac27dfb into staging May 14, 2024
2 checks passed
@levadadenys levadadenys deleted the denys/design2/design2-108 branch May 14, 2024 10:36
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.

None yet

3 participants