Skip to content

chore(DefaultDisclosureSummary): new render props - #2754

Open
GermanVor wants to merge 4 commits into
mainfrom
disclosure-render-props
Open

GermanVor wants to merge 4 commits into
mainfrom
disclosure-render-props

Conversation

@GermanVor

@GermanVor GermanVor commented Jul 16, 2026 •

Copy link
Copy Markdown
Contributor

WIP

Summary by Sourcery

Add layout customization options to Disclosure.Summary and expose the default summary component for reuse.

New Features:

  • Introduce width and justifyContent render props to DisclosureSummary to control trigger width and content alignment.
  • Expose DefaultDisclosureSummary via DisclosureSummary.Default for easier access to the default summary implementation.

Enhancements:

  • Extend Disclosure summary styles to support full-width triggers and space-between content alignment.
  • Update Russian and English Disclosure.Summary documentation to describe the new layout props and defaults.

@GermanVor
GermanVor requested a review from Raubzeug as a code owner July 16, 2026 13:30
@sourcery-ai

sourcery-ai Bot commented Jul 16, 2026 •

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Adds layout-related render props to Disclosure.Summary and wires them through the default summary implementation and styles, exposing DefaultDisclosureSummary as a static member on DisclosureSummary.

File-Level Changes

Change Details Files
Extend DisclosureSummary render props with width and justifyContent options and apply them to the default trigger button.
  • Introduce DisclosureSummaryWidth and DisclosureSummaryJustifyContent type aliases for allowed values.
  • Add optional width and justifyContent fields to DisclosureSummaryRenderFunctionProps interface.
  • Destructure width and justifyContent in DefaultDisclosureSummary and pass them as modifiers to the BEM class builder for the trigger button.
src/components/Disclosure/DisclosureSummary/DisclosureSummary.tsx
Document new width and justifyContent props for Disclosure.Summary in both English and Russian READMEs.
  • Update Disclosure.Summary API tables to include width and justifyContent with descriptions, allowed string values, and defaults.
  • Adjust column formatting to align with the extended property list.
src/components/Disclosure/README.md
src/components/Disclosure/README-ru.md
Add CSS modifiers to support full-width and space-between justification for the Disclosure trigger button and expose the default summary implementation via a static property.
  • Define BEM modifier class for making the trigger 100% width when width="max".
  • Define BEM modifier class for applying justify-content: space-between when justifyContent="space-between".
  • Assign DefaultDisclosureSummary to DisclosureSummary.Default so consumers can reuse the library’s default rendering from custom children.
src/components/Disclosure/Disclosure.scss
src/components/Disclosure/DisclosureSummary/DisclosureSummary.tsx

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • The justifyContent values in types/implementation ('initial' | 'space-between' and justify-content_space-between class) don’t match the README docs ("start" | "space-between"), so please align the API, styles, and documentation on a single set of allowed values.
  • README now describes width and justifyContent as Disclosure.Summary props, but in this diff they are only added to DefaultDisclosureSummary render props; if these are intended as top-level Summary props, please wire them through the main component as well.
  • Consider explicitly handling the default cases for width and justifyContent in styles (e.g., modifiers or clear defaults for auto/start) so that the behavior is predictable and consistent when these props are omitted.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The `justifyContent` values in types/implementation (`'initial' | 'space-between'` and `justify-content_space-between` class) don’t match the README docs (`"start" | "space-between"`), so please align the API, styles, and documentation on a single set of allowed values.
- README now describes `width` and `justifyContent` as `Disclosure.Summary` props, but in this diff they are only added to `DefaultDisclosureSummary` render props; if these are intended as top-level `Summary` props, please wire them through the main component as well.
- Consider explicitly handling the default cases for `width` and `justifyContent` in styles (e.g., modifiers or clear defaults for `auto`/`start`) so that the behavior is predictable and consistent when these props are omitted.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@gravity-ui

gravity-ui Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Preview is ready.

@gravity-ui

gravity-ui Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

🎭 Component Tests Report is ready.

@Raubzeug Raubzeug left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

One API issue to address:

disabled?: boolean;
className?: string;
width?: DisclosureSummaryWidth;
justifyContent?: DisclosureSummaryJustifyContent;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

width and justifyContent are documented as Disclosure.Summary props, but they are declared on DisclosureSummaryRenderFunctionProps. DisclosureSummary does not include either value in the object passed to the render function, while DisclosureSummaryProps does not accept them at all. As a result, the API shown in the README cannot type-check. Could we move these options to DisclosureSummaryProps and pass them to the default summary when it is created?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks — the new props are now accepted by DisclosureSummaryProps, but the render-function contract is still expanded and all layout/content values are included in props (lines 74–86). This breaks the documented {(props) => <Button {...props}>…} path: a size="xl" Disclosure now changes the custom Button to xl and adds width_auto, while summary is forwarded to the DOM and React warns about justifyContent/arrowPosition. I reproduced this against the current head. Could we keep render props interaction-only and introduce separate DefaultDisclosureSummaryProps (or pass these values only when building defaultSummary)?

}

export type DisclosureSummaryWidth = 'auto' | 'max';
export type DisclosureSummaryJustifyContent = 'initial' | 'space-between';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The implementation accepts "initial" | "space-between", while both READMEs document "start" | "space-between". This makes the documented justifyContent="start" value invalid in TypeScript. Could we use the same values throughout? I would prefer "start" | "space-between" because initial is a CSS-wide keyword rather than a semantic layout option.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

);
});

DisclosureSummary.Default = DefaultDisclosureSummary;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Non-blocking suggestion: if width and justifyContent become DisclosureSummaryProps, would it make sense to make children optional and render defaultSummary when it is omitted? That would support <Disclosure.Summary width="max" justifyContent="space-between" /> without forcing consumers to recreate Disclosure.Summary.Default and spread the interaction props manually. The existing render-function behavior could remain unchanged whenever children is provided.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

had to add more props for <Disclosure.Summary width="max" justifyContent="space-between" />

2c77faf

width: 100%;
}
&__trigger_justify-content_space-between {
justify-content: space-between;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could we add regression coverage for these new layout modifiers? At minimum, a component test should verify that width_max and justify-content_space-between are applied and that omitting the props preserves the current classes. A Storybook or visual case with an end-positioned arrow and a long summary would also verify that the full-width layout behaves as intended.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

>
<ArrowToggle
size={ComponentSizeToIconSizeMap[size]}
size={ComponentSizeToIconSizeMap[mergedSize]}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

size currently overrides only the ArrowToggle icon through mergedSize. The trigger typography is still selected by the parent .g-disclosure_size_* .g-disclosure__trigger rules, so <Disclosure size="m"><Disclosure.Summary size="xl" /></Disclosure> renders an xl icon with m text. This contradicts the documented “overrides Disclosure.size” contract. Could we either remove this extra override from the scope, or add a trigger-level size modifier so the entire summary changes size?

children: renderFunction,
qa,
justifyContent = 'start',
width = 'auto',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Defaulting these values here adds _width_auto and _justify-content_start classes (and explicit CSS declarations) to every existing Disclosure, including the implicit summary path. That changes the DOM/CSS contract and may override consumer styles, while the browser’s natural flex defaults already provide the same auto/start behavior. Could we keep both values undefined when omitted and emit modifier classes only for explicit props? The omitted-props test should then assert that these new classes are absent.

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