Skip to content

fix: use details/summary for accordion COMPASS-9734#7653

Draft
paula-stacho wants to merge 3 commits intomainfrom
COMPASS-9734-2
Draft

fix: use details/summary for accordion COMPASS-9734#7653
paula-stacho wants to merge 3 commits intomainfrom
COMPASS-9734-2

Conversation

@paula-stacho
Copy link
Copy Markdown
Collaborator

Description

Checklist

  • New tests and/or benchmarks are included
  • Documentation is changed or added
  • If this change updates the UI, screenshots/videos are added and a design review is requested
  • If this change could impact the load on the MongoDB cluster, please describe the expected and worst case impact
  • I have signed the MongoDB Contributor License Agreement (https://www.mongodb.com/legal/contributor-agreement)

Motivation and Context

  • Bugfix
  • New feature
  • Dependency update
  • Misc

Open Questions

Dependents

Types of changes

  • Backport Needed
  • Patch (non-breaking change which fixes an issue)
  • Minor (non-breaking change which adds functionality)
  • Major (fix or feature that would cause existing functionality to change)

@github-actions github-actions bot added the fix label Dec 15, 2025
@paula-stacho paula-stacho changed the title fix: use details/summary for accordion COMPASS-9734 refactor: use details/summary for accordion COMPASS-9734 Dec 15, 2025
@paula-stacho paula-stacho changed the title refactor: use details/summary for accordion COMPASS-9734 fix: use details/summary for accordion COMPASS-9734 Dec 15, 2025
@paula-stacho paula-stacho added the no release notes Fix or feature not for release notes label Dec 15, 2025
});
},
[setOpenRef]
);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Aren't we basically reimplementing the behavior that details + summary have in plain HTML here? Not a bad thing, just wondering if we need this

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This is allowing for a controlled version. I'm not sure if we actually need the controlled version though, I'll go through the use cases and see if this could be simplified.

Copilot AI review requested due to automatic review settings April 10, 2026 14:13
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR migrates the shared Accordion component to a native <details>/<summary> implementation and updates consuming UI components plus e2e/helpers/tests to match the new DOM structure and callback naming.

Changes:

  • Refactors packages/compass-components Accordion to render as <details>/<summary> and renames related props (setOpenonOpenToggle, buttonTextClassNamesummaryTextClassName).
  • Updates multiple feature packages (connection form, CSFLE tab, indexes, data modeling drawer, global writes) to use the new Accordion props.
  • Updates e2e accordion interaction helpers and the Accordion unit test to reflect the new open-state mechanism.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
packages/connection-form/src/components/connection-form.tsx Switches advanced options accordion integration to onOpenToggle.
packages/connection-form/src/components/advanced-options-tabs/csfle-tab/csfle-tab.tsx Updates CSFLE provider accordions to onOpenToggle.
packages/connection-form/src/components/advanced-connection-options.tsx Updates prop typing and wiring to onOpenToggle.
packages/compass-indexes/src/components/create-index-form/create-index-form.tsx Updates accordion telemetry hook to onOpenToggle.
packages/compass-global-writes/src/components/create-shard-key-form.tsx Removes externally-controlled open state for the accordion.
packages/compass-e2e-tests/helpers/commands/expand-accordion.ts Updates accordion expansion logic to click <summary> and check open.
packages/compass-e2e-tests/helpers/commands/connect-form.ts Updates collapse wait condition to use the open attribute.
packages/compass-data-modeling/src/components/drawer/drawer-section-components.tsx Renames styling prop to summaryTextClassName.
packages/compass-components/src/components/accordion.tsx Core refactor to <details>/<summary> implementation.
packages/compass-components/src/components/accordion.spec.tsx Updates unit assertions for the new DOM/open state.

Comment on lines +99 to +100
(event: React.SyntheticEvent<HTMLElement>) => {
const isOpen = (event.target as HTMLDetailsElement).open;
Comment on lines 105 to +107
return (
<>
<button
{...props}
<details open={defaultOpen} onToggle={handleToggle}>
<summary
Comment on lines 112 to 116
textClassName
)}
id={labelId}
type="button"
aria-expanded={open ? 'true' : 'false'}
aria-controls={regionId}
onClick={onOpenChange}
{...props}
>
Comment on lines +127 to +131
</summary>

{open && (
<div role="region" aria-labelledby={labelId} id={regionId}>
{props.children}
</div>
)}
</>
<div role="region" aria-labelledby={labelId}>
{props.children}
</div>
await expandButton.click();
const isOpen = await accordion.getAttribute('open');

if (!isOpen) {
Comment on lines +303 to +306
const advancedAccordion = browser.$(
Selectors.ConnectionFormAdvancedToggle
);
return (await advancedAccordion.getAttribute('open')) === null;
Comment on lines 19 to 26
it('should open the accordion on click', function () {
renderAccordion();

expect(screen.getByTestId('my-test-id')).to.exist;
const button = screen.getByText('Accordion Test');
userEvent.click(button);
expect(screen.getByText('Hello World')).to.be.visible;
const summary = screen.getByText('Accordion Test');
userEvent.click(summary);
expect(summary.closest('details')).to.have.attribute('open');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix no release notes Fix or feature not for release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants