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

refactor(components): add optional data id to Titled List component #6041

Merged
merged 4 commits into from
Jul 6, 2020

Conversation

shlokamin
Copy link
Member

@shlokamin shlokamin commented Jul 1, 2020

Overview

This PR partially addresses #5725 by adding an optional data-id to the container wrapping the TitledList component in component library. I also updated the relevant PD cypress test to use the new data-id as a selector.

Changelog

  • Add optional data-id to TitledList component
  • Update PD cypress tests to use new data-id in selectors

Review requests

Code review
E2E tests still pass

Risk assessment

Low

@shlokamin shlokamin requested review from mcous, Kadee80 and IanLondon July 1, 2020 17:34
@shlokamin shlokamin requested a review from a team as a code owner July 1, 2020 17:34
@shlokamin shlokamin requested a review from a team July 1, 2020 17:34
@shlokamin shlokamin changed the title refactor(components): add optional id prop to titled list component refactor(components): add optional id to Titled List component Jul 1, 2020
@shlokamin shlokamin changed the title refactor(components): add optional id to Titled List component refactor(components): add optional data id to Titled List component Jul 1, 2020
@@ -13,6 +13,8 @@ export type TitledListProps = {|
iconName?: ?IconName,
/** props passed down to icon (`className` and `name` are ignored) */
iconProps?: $Diff<React.ElementProps<typeof Icon>, { name: mixed }>,
/** optional ID for the container */
dataId?: string,
Copy link
Contributor

Choose a reason for hiding this comment

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

so that we don't need to think about dataId vs data-id, could we make this prop data-id instead, mirroring the native element attr?

It would be a bit annoying in the component itself bc of the dash, so when destructuring props we'd have to do const {'data-id': dataId} = props instead of the simpler const {dataId} = props.

But the benefit is, when using/consuming these components, we can use the same prop as we'd use for a native element:

<div data-id="Something">
  <Spam data-id="Spam" />
<div>

instead of 2 different props for the same attr

<div data-id="Something">
  <Spam dataId="Spam" />
<div>

Copy link
Contributor

Choose a reason for hiding this comment

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

Agree. FWIW, this is the same convention as React: dash-case becomes camelCase except in the case of data and ARIA attributes

Copy link
Member Author

Choose a reason for hiding this comment

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

Done!

@shlokamin shlokamin requested a review from IanLondon July 2, 2020 16:24
Copy link
Contributor

@IanLondon IanLondon left a comment

Choose a reason for hiding this comment

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

🍨

@shlokamin shlokamin merged commit 7f935f3 into edge Jul 6, 2020
@shlokamin shlokamin deleted the components_titled-list-id branch July 6, 2020 14:53
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.

3 participants