Skip to content

feat(Details): Add summary subcomponent - #5015

Merged
francinelucca merged 31 commits into
mainfrom
francinelucca/fix/3518-prcdetails-component-does-not-provide-appropriate-structure-by-default
Oct 31, 2024
Merged

feat(Details): Add summary subcomponent#5015
francinelucca merged 31 commits into
mainfrom
francinelucca/fix/3518-prcdetails-component-does-not-provide-appropriate-structure-by-default

Conversation

@francinelucca

@francineluccafrancinelucca commented Sep 24, 2024

Copy link
Copy Markdown
Member

Closeshttps://github.com/github/primer/issues/3518

Adds Details.Summary subcomponent that can be used within Details for the summary and adds summary prop to Details component which will render the supplied node within the new Details.Summary subcomponent. Also adds a default "See Details" summary value to be rendered to improve accessibility in case authors fail to supply one.

Changelog

New

  • Adds Details.Summary subcomponent
  • Adds tests for new Details.Summary subcomponent

Changed

  • Updates Details.docs.json to include data for new Details.Summary subcomponent and its props
  • Use new Details.Summary subcomponent in Details story
  • Refactor Details component to render a default Details.Summary if one hasn't been supplied by author
  • Rewrite Details component export to include new Details.Summary subcomponent
  • Update Details tests to use new Details.Summary subcomponent

Rollout strategy

  • Patch release
  • Minor release
  • Major release; if selected, include a written rollout or migration plan
  • None; if selected, include a brief description as to why

Testing & Reviewing

  • Verify no visual/behavioral regressions in deploy preview Details story
  • All tests should pass sniff test and CI

Merge checklist

@changeset-bot

changeset-botBot commented Sep 24, 2024

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: e6ce3b3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
NameType
@primer/reactMinor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@francineluccafrancinelucca added the staff Author is a staff member label Sep 24, 2024
@github-actions
github-actionsBottemporarily deployed to storybook-preview-5015 September 24, 2024 15:38 Inactive
@github-actions

github-actionsBot commented Sep 24, 2024

Copy link
Copy Markdown
Contributor

size-limit report 📦

PathSize
packages/react/dist/browser.esm.js97.94 KB (+0.19% 🔺)
packages/react/dist/browser.umd.js98.25 KB (+0.21% 🔺)

@francineluccafrancinelucca changed the title fix(Details): Add summary prop and subcomponentfeat(Details): Add summary prop and subcomponentSep 24, 2024
@github-actions
github-actionsBottemporarily deployed to storybook-preview-5015 September 24, 2024 18:48 Inactive
siddharthkp
siddharthkp previously requested changes Oct 2, 2024

@siddharthkpsiddharthkp left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is really good and thorough work!

Mostly clarifying questions, 1 suggestion

<Details summary="test summary" data-testid="details">
<Details.Summary>custom summary</Details.Summary>
content
</Details>,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

(non blocker) Should this also be a dev warning? example of warning

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

superseeded by bac525a

)

expect(queryByText('See Details')).toBeNull()
expect(getByTestId('summary')).toBeInTheDocument()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

(just a note) TIL you can't getByRole('summary'), it's inferred as a button instead!

}
]
}
]

@siddharthkpsiddharthkpOct 2, 2024

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

(blocking) summary prop is missing from docs.

Curious, should we prefer adding just 1 approach instead of both <Details summary> and <Details.Summary>? To me, <Details.Summary> feels like the closest replacement for <summary>, which feels complete.

Would like to hear your thoughts on the 2 approaches though!

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Thought about this and I agree with you. I think originally I was going for the "maximize ease-of-use" approach but in hindsight this might be confusing and adds extra complexity with having to support the intersection of both strategies (Re: your comment here).

Going to refactor to just introduce Details.Summary and render a default one if one isn't present, that feels right-er to me as well.
Wondering, do you think that would warrant a warning as well? (The use case where a Details component is used but neither Details.Summary nor a native summary is present within the children).

return (
<Details {...getDetailsProps()}>
<Button as="summary">See Details</Button>
<Details.Summary as={Button}>See Details</Details.Summary>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Couple noob questions here:

  1. Assuming this renders a <button>, is that still accessible with <details>?
  2. Just checking, does this also support ButtonProps like size=small and variant=primary`?

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

  1. Note sure what accessible with details means 😅, here's how/what it renders:
image is there some specific behavior you want me to test for here?
  1. Had to fiddle with the types a little but yeah those work:
imageimage

…/3518-prcdetails-component-does-not-provide-appropriate-structure-by-default
…/3518-prcdetails-component-does-not-provide-appropriate-structure-by-default
@github-actions
github-actionsBottemporarily deployed to storybook-preview-5015 October 23, 2024 21:24 Inactive
@github-actions
github-actionsBottemporarily deployed to storybook-preview-5015 October 23, 2024 21:29 Inactive
@francineluccafrancinelucca added integration-tests: passing Changes in this PR do NOT cause breaking changes in gh/gh and removed integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm labels Oct 23, 2024
…/3518-prcdetails-component-does-not-provide-appropriate-structure-by-default

@jonrohanjonrohan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Great!

…does-not-provide-appropriate-structure-by-default
@primer-integration

Copy link
Copy Markdown

👋 Hi from github/github! Your integration PR is ready: https://github.com/github/github/pull/349552

@francinelucca
francinelucca removed the request for review from siddharthkpOctober 31, 2024 21:47
@primerprimerBot mentioned this pull request Oct 31, 2024
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration-tests: passingChanges in this PR do NOT cause breaking changes in gh/ghstaffAuthor is a staff memberstatus: review needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@francinelucca@jonrohan@siddharthkp@joshblack