Skip to content

Conversation

@KMNowak
Copy link

@KMNowak KMNowak commented Oct 18, 2025

Closes #

📝 Description

  • Added optional propertytransitionDuration (default 300ms just like in Framer), to customize behaviour
  • Added optional property scrollOnOpen to scroll automatically to just opened accordion item to increase content visibility.

⛳️ Current behavior (updates)

Currently it was not possible to customize animation duration time.

🚀 New behavior

User can customize animation duration time and additionally apply automatic scroll to just opened accordion item.

💣 Is this a breaking change (Yes/No):

No

📝 Additional Information

Applied changes suggested in original PR: #5126

Summary by CodeRabbit

  • New Features

    • Added scrollOnOpen (defaults to false) to auto-scroll expanded accordion items into view.
    • Added transitionDuration (defaults to 300ms) to customize accordion animation speed.
  • Documentation

    • Added demos and docs showcasing scroll-on-open and multiple transition-duration examples, plus Storybook entries.
  • Tests

    • Added tests validating scroll-on-open behavior and that custom transitionDuration values affect animations.

@KMNowak KMNowak requested a review from jrgarciadev as a code owner October 18, 2025 21:55
@changeset-bot
Copy link

changeset-bot bot commented Oct 18, 2025

🦋 Changeset detected

Latest commit: 057eda1

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

This PR includes changesets to release 2 packages
Name Type
@heroui/accordion Patch
@heroui/react Patch

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

@vercel
Copy link

vercel bot commented Oct 18, 2025

@KMNowak is attempting to deploy a commit to the HeroUI Inc Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 18, 2025

Walkthrough

Adds two optional Accordion props — scrollOnOpen?: boolean and transitionDuration?: number — and propagates them through core hooks, AccordionItem rendering (scroll + animation duration), tests, stories, documentation, demos, index, and a changeset entry.

Changes

Cohort / File(s) Summary
Core hooks
packages/components/accordion/src/use-accordion.ts, packages/components/accordion/src/use-accordion-item.ts
Added scrollOnOpen?: boolean and transitionDuration?: number to Props and return values; defaults false and 300; propagated through values, memos, dependency arrays, and return signatures.
Accordion item implementation
packages/components/accordion/src/accordion-item.tsx
Added contentRef and useLayoutEffect to call scrollIntoView() when isOpen && scrollOnOpen; transition variants use transitionDuration (ms→s); ref attached across all content render paths.
Tests
packages/components/accordion/__tests__/accordion.test.tsx
Added tests for scroll-on-open (mocking scrollIntoView) and for custom transitionDuration timing (style assertions and timed waits).
Stories
packages/components/accordion/stories/accordion.stories.tsx
Added WithScrollOnOpen and WithCustomTransitionDuration stories/templates; minor import reorder.
Docs & demos
apps/docs/content/components/accordion/scroll-on-open.raw.jsx, apps/docs/content/components/accordion/scroll-on-open.ts, apps/docs/content/components/accordion/transition-duration.raw.jsx, apps/docs/content/components/accordion/transition-duration.ts, apps/docs/content/docs/components/accordion.mdx
New demo components showcasing scrollOnOpen and multiple transitionDuration values; documentation updated to include new props and API table entries.
Docs index & changelog
apps/docs/content/components/accordion/index.ts, .changeset/shy-kiwis-bake.md
Exported new demo entries in index and added a changeset patch entry for the Accordion release.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Accordion
    participant AccordionItem
    participant ContentRef as contentRef

    User->>Accordion: click header
    Accordion->>AccordionItem: toggle isOpen
    AccordionItem->>AccordionItem: run animation (duration = transitionDuration || 300ms)
    alt scrollOnOpen = true
        AccordionItem->>AccordionItem: useLayoutEffect on isOpen && scrollOnOpen
        Note right of AccordionItem #e6f7ff: double requestAnimationFrame to wait for layout
        AccordionItem->>ContentRef: contentRef.scrollIntoView({ behavior: "smooth", block: "nearest" })
    end
    AccordionItem-->>User: content rendered/expanded
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Review focus: packages/components/accordion/src/accordion-item.tsx (scroll effect and ref attachments), tests in __tests__, and story/demo correctness.

Suggested reviewers

  • jrgarciadev

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The pull request title "feat(accordion): add transitionDuration and scrollOnOpen props" is clear, concise, and directly related to the main changes in the changeset. It uses semantic commit convention and accurately summarizes the primary change: the addition of two new optional props to the Accordion component. The title is specific enough for a developer scanning history to understand the focus of the PR without being overly verbose.
Description Check ✅ Passed The pull request description follows the provided template structure and includes most required sections with meaningful content. The Description section explains the two new properties and their purposes, the Current behavior section describes the limitation being addressed, the New behavior section outlines the new functionality, the breaking change question is answered, and Additional Information provides context about the related original PR. While the "Closes #" field still contains the template placeholder rather than an actual issue number, all substantive sections are properly filled in with relevant details about the changes.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (4)
.changeset/shy-kiwis-bake.md (1)

5-6: Minor: Simplify the phrasing.

The phrase "as it is right now" is slightly informal for a changelog. Consider simplifying to maintain consistency with release note conventions.

Apply this diff:

-- Introduce new prop `transitionDuration?: number` to customize animation speed. Defaults to 300ms as it is right now
+- Introduce new prop `transitionDuration?: number` to customize animation speed. Defaults to 300ms
packages/components/accordion/stories/accordion.stories.tsx (2)

379-401: Good showcase for scrollOnOpen

Template correctly uses a scrollable container to demonstrate behavior. Consider adding Storybook controls so consumers can toggle scrollOnOpen on any story.

Apply this (outside this hunk) to expose controls:

   argTypes: {
+    scrollOnOpen: {
+      control: {type: "boolean"},
+    },
+    transitionDuration: {
+      control: {type: "number", min: 0, max: 3000, step: 50},
+      table: {type: {summary: "number (ms)"}, defaultValue: {summary: 300}},
+    },
   },

Based on learnings.


402-429: Nice coverage of fast/slow durations

Clear contrast between 150ms and 800ms. Consider adding one example wired to args.transitionDuration so users can live-edit the value via controls (pairs well with the argTypes suggestion above).

packages/components/accordion/src/accordion-item.tsx (1)

82-93: Preserve existing easing/type when applying custom duration

Replacing the entire transition may drop easing/type from TRANSITION_VARIANTS. Merge and set per‑property durations to keep behavior consistent.

-    const transitionVariants: Variants = {
-      exit: {
-        ...TRANSITION_VARIANTS.collapse.exit,
-        overflowY: "hidden",
-        transition: {duration: transitionDuration ? transitionDuration / 1000 : 0.3},
-      },
-      enter: {
-        ...TRANSITION_VARIANTS.collapse.enter,
-        overflowY: "unset",
-        transition: {duration: transitionDuration ? transitionDuration / 1000 : 0.3},
-      },
-    };
+    const dur = (transitionDuration ?? 300) / 1000;
+    const transitionVariants: Variants = {
+      exit: {
+        ...TRANSITION_VARIANTS.collapse.exit,
+        overflowY: "hidden",
+        transition: {
+          ...(TRANSITION_VARIANTS.collapse.exit as any).transition,
+          height: {...(TRANSITION_VARIANTS.collapse.exit as any)?.transition?.height, duration: dur},
+          opacity: {...(TRANSITION_VARIANTS.collapse.exit as any)?.transition?.opacity, duration: dur},
+        },
+      },
+      enter: {
+        ...TRANSITION_VARIANTS.collapse.enter,
+        overflowY: "visible",
+        transition: {
+          ...(TRANSITION_VARIANTS.collapse.enter as any).transition,
+          height: {...(TRANSITION_VARIANTS.collapse.enter as any)?.transition?.height, duration: dur},
+          opacity: {...(TRANSITION_VARIANTS.collapse.enter as any)?.transition?.opacity, duration: dur},
+        },
+      },
+    };

If you prefer to keep types strict, mirror the structure of TRANSITION_VARIANTS locally instead of casting.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b38a2cf and a2fdaa9.

📒 Files selected for processing (12)
  • .changeset/shy-kiwis-bake.md (1 hunks)
  • apps/docs/content/components/accordion/index.ts (2 hunks)
  • apps/docs/content/components/accordion/scroll-on-open.raw.jsx (1 hunks)
  • apps/docs/content/components/accordion/scroll-on-open.ts (1 hunks)
  • apps/docs/content/components/accordion/transition-duration.raw.jsx (1 hunks)
  • apps/docs/content/components/accordion/transition-duration.ts (1 hunks)
  • apps/docs/content/docs/components/accordion.mdx (2 hunks)
  • packages/components/accordion/__tests__/accordion.test.tsx (1 hunks)
  • packages/components/accordion/src/accordion-item.tsx (6 hunks)
  • packages/components/accordion/src/use-accordion-item.ts (3 hunks)
  • packages/components/accordion/src/use-accordion.ts (6 hunks)
  • packages/components/accordion/stories/accordion.stories.tsx (3 hunks)
🧰 Additional context used
🧬 Code graph analysis (5)
apps/docs/content/components/accordion/scroll-on-open.ts (1)
apps/docs/content/components/accordion/scroll-on-open.raw.jsx (1)
  • App (3-65)
apps/docs/content/components/accordion/transition-duration.ts (1)
apps/docs/content/components/accordion/transition-duration.raw.jsx (1)
  • App (3-67)
packages/components/accordion/stories/accordion.stories.tsx (2)
packages/components/accordion/src/accordion.tsx (1)
  • AccordionProps (9-9)
packages/components/accordion/src/index.ts (3)
  • AccordionProps (5-5)
  • Accordion (14-14)
  • AccordionItem (14-14)
apps/docs/content/components/accordion/scroll-on-open.raw.jsx (1)
apps/docs/content/components/accordion/transition-duration.raw.jsx (2)
  • App (3-67)
  • defaultContent (4-5)
apps/docs/content/components/accordion/transition-duration.raw.jsx (1)
apps/docs/content/components/accordion/scroll-on-open.raw.jsx (2)
  • App (3-65)
  • defaultContent (4-5)
🪛 LanguageTool
.changeset/shy-kiwis-bake.md

[grammar] ~6-~6: Ensure spelling is correct
Context: ... customize animation speed. Defaults to 300ms as it is right now

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)

🔇 Additional comments (13)
packages/components/accordion/src/use-accordion-item.ts (1)

38-47: LGTM! Clean prop additions with sensible defaults.

The new props are well-documented, use reasonable defaults (300ms matches common animation standards, scrollOnOpen disabled by default to avoid surprising behavior), and are properly threaded through the hook's return value.

Also applies to: 77-78, 284-285

packages/components/accordion/src/use-accordion.ts (1)

48-57: LGTM! Consistent parent hook implementation.

The props are properly threaded through the accordion parent hook, included in the values context payload, dependency arrays, and return object. This ensures child items receive the configuration correctly.

Also applies to: 84-85, 118-119, 212-213, 228-229, 265-266

apps/docs/content/components/accordion/index.ts (1)

17-18: LGTM! Proper documentation integration.

The new demo imports and exports follow the existing pattern for accordion documentation examples.

Also applies to: 37-38

apps/docs/content/components/accordion/scroll-on-open.ts (1)

1-9: LGTM! Standard documentation demo module.

This follows the established pattern for exposing demo components to the documentation system.

apps/docs/content/components/accordion/transition-duration.ts (1)

1-9: LGTM! Standard documentation demo module.

This follows the established pattern for exposing demo components to the documentation system.

packages/components/accordion/__tests__/accordion.test.tsx (2)

382-410: LGTM! Reasonable timing verification for custom duration.

The test validates that the custom transition duration is respected by checking opacity values during and after the animation. The customDuration + 10ms buffer is reasonable for allowing Framer Motion to complete its animation cycle.


350-380: Remove the timing concern—100ms wait is sufficient for the implementation.

The actual scrollIntoView implementation in accordion-item.tsx (line 52-57) uses a 50ms setTimeout before calling scrollIntoView. The test waits 100ms before asserting, which provides a 50ms buffer. The mocked scrollIntoView call completes synchronously (it's a mock, not the actual browser implementation), so the 100ms wait is adequate and not prone to flakiness in CI environments.

Likely an incorrect or invalid review comment.

apps/docs/content/docs/components/accordion.mdx (1)

125-135: LGTM! Comprehensive documentation for new features.

The documentation clearly explains both new props with live demos and accurate API table entries. The placement in the docs flow is logical, and the default values match the implementation.

Also applies to: 296-307

apps/docs/content/components/accordion/transition-duration.raw.jsx (1)

7-66: Demo looks good

Accurately showcases the new transitionDuration prop with sensible examples. No issues found.

packages/components/accordion/stories/accordion.stories.tsx (2)

19-19: Import reorder is fine

Reordered named imports to include AccordionItem/Props alongside Accordion/Props. No behavior change.


583-597: Exports are wired correctly

Stories render the new templates with default props. LGTM.

apps/docs/content/components/accordion/scroll-on-open.raw.jsx (1)

7-64: Clear side‑by‑side demo

Accurately demonstrates behavior with and without scrollOnOpen in realistic scroll containers. No issues.

packages/components/accordion/src/accordion-item.tsx (1)

109-112: Ref usage is correct

Attaching contentRef in both animated and non‑animated branches ensures the scroll target is present. LGTM.

Please confirm that use-accordion-item forwards scrollOnOpen/transitionDuration from Accordion to AccordionItem in all selection modes.

Also applies to: 130-133, 75-79

@KMNowak KMNowak force-pushed the feat/accordion_transitionDuration_and_scrollOnOpen branch from a2fdaa9 to cd857c6 Compare October 18, 2025 22:04
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (3)
.changeset/shy-kiwis-bake.md (1)

6-6: Simplify the wording for clarity.

The phrase "as it is right now" is informal and slightly awkward. Consider simplifying to just "Defaults to 300ms" since this is establishing the default behavior going forward.

Apply this diff:

-- Introduce new prop `transitionDuration?: number` to customize animation speed. Defaults to 300ms as it is right now
+- Introduce new prop `transitionDuration?: number` to customize animation speed. Defaults to 300ms
apps/docs/content/components/accordion/transition-duration.raw.jsx (1)

1-67: Demo effectively showcases transitionDuration prop.

The component clearly demonstrates the new transitionDuration prop with four different speeds (150ms, 300ms, 800ms, 1200ms). The responsive grid layout and descriptive headings make the differences easy to compare.

Optional: The defaultContent string on lines 4-5 is duplicated in scroll-on-open.raw.jsx. If these demos are intended to be reusable, consider extracting the shared Lorem Ipsum text to a common constants file. However, since these are standalone documentation examples, the duplication is acceptable.

apps/docs/content/components/accordion/scroll-on-open.raw.jsx (1)

1-65: Excellent side-by-side comparison demonstrating scrollOnOpen.

The demo effectively showcases the scrollOnOpen behavior through a clear side-by-side comparison. The scrollable containers with spacer content create a realistic scenario where the feature provides value, and the inclusion of the Button components nicely illustrates how interactive elements benefit from auto-scrolling.

Optional: The defaultContent string (lines 4-5) is duplicated in transition-duration.raw.jsx. Consider extracting to a shared constant if consolidating demo utilities in the future, though the current approach is acceptable for standalone examples.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a2fdaa9 and cd857c6.

📒 Files selected for processing (6)
  • .changeset/shy-kiwis-bake.md (1 hunks)
  • apps/docs/content/components/accordion/index.ts (2 hunks)
  • apps/docs/content/components/accordion/scroll-on-open.raw.jsx (1 hunks)
  • apps/docs/content/components/accordion/scroll-on-open.ts (1 hunks)
  • apps/docs/content/components/accordion/transition-duration.raw.jsx (1 hunks)
  • apps/docs/content/components/accordion/transition-duration.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • apps/docs/content/components/accordion/transition-duration.ts
  • apps/docs/content/components/accordion/scroll-on-open.ts
  • apps/docs/content/components/accordion/index.ts
🧰 Additional context used
🧬 Code graph analysis (2)
apps/docs/content/components/accordion/scroll-on-open.raw.jsx (1)
apps/docs/content/components/accordion/transition-duration.raw.jsx (2)
  • App (3-67)
  • defaultContent (4-5)
apps/docs/content/components/accordion/transition-duration.raw.jsx (1)
apps/docs/content/components/accordion/scroll-on-open.raw.jsx (2)
  • App (3-65)
  • defaultContent (4-5)
🪛 LanguageTool
.changeset/shy-kiwis-bake.md

[grammar] ~6-~6: Ensure spelling is correct
Context: ... customize animation speed. Defaults to 300ms as it is right now

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)

@KMNowak KMNowak force-pushed the feat/accordion_transitionDuration_and_scrollOnOpen branch from c209bd0 to 8c5975f Compare October 18, 2025 22:22
@KMNowak
Copy link
Author

KMNowak commented Oct 18, 2025

@coderabbitai review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 18, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
packages/components/accordion/src/accordion-item.tsx (1)

105-116: Consider extracting duration calculation to reduce duplication.

The expression transitionDuration ? transitionDuration / 1000 : 0.3 is duplicated in both exit and enter variants. While minor, extracting it improves maintainability.

Apply this diff to extract the duration:

+    const duration = transitionDuration ? transitionDuration / 1000 : 0.3;
+
     const transitionVariants: Variants = {
       exit: {
         ...TRANSITION_VARIANTS.collapse.exit,
         overflowY: "hidden",
-        transition: {duration: transitionDuration ? transitionDuration / 1000 : 0.3},
+        transition: {duration},
       },
       enter: {
         ...TRANSITION_VARIANTS.collapse.enter,
         overflowY: "unset",
-        transition: {duration: transitionDuration ? transitionDuration / 1000 : 0.3},
+        transition: {duration},
       },
     };
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c209bd0 and 8c5975f.

📒 Files selected for processing (1)
  • packages/components/accordion/src/accordion-item.tsx (6 hunks)
🔇 Additional comments (6)
packages/components/accordion/src/accordion-item.tsx (6)

3-3: LGTM: Imports are correctly added.

The new imports (ReactNode, useRef, useLayoutEffect) are properly used in the implementation.

Also applies to: 6-6


34-35: LGTM: New props are correctly destructured.

The scrollOnOpen and transitionDuration props are properly extracted from the hook and used throughout the component.


46-46: LGTM: Content ref is properly initialized.

The contentRef is correctly typed and will be attached to content wrapper elements.


89-103: LGTM: Content ref is correctly attached in non-animated paths.

Both the keepContentMounted and conditional render branches properly attach contentRef to the content wrapper.


132-134: LGTM: Content ref is correctly attached in animated paths.

The contentRef is properly attached to the content wrapper in both the keepContentMounted (line 132) and AnimatePresence (line 153) render paths, ensuring the scroll effect can access the DOM node.

Also applies to: 153-155


161-161: LGTM: Dependency array correctly updated.

The transitionDuration prop is correctly added to the useMemo dependencies since it affects the transitionVariants object.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
packages/components/accordion/src/accordion-item.tsx (1)

109-120: Consider nullish coalescing for clarity.

The transition duration logic is correct, but could be slightly clearer by making the default explicit in milliseconds.

Apply this diff for improved clarity:

 const transitionVariants: Variants = {
   exit: {
     ...TRANSITION_VARIANTS.collapse.exit,
     overflowY: "hidden",
-    transition: {duration: transitionDuration ? transitionDuration / 1000 : 0.3},
+    transition: {duration: (transitionDuration ?? 300) / 1000},
   },
   enter: {
     ...TRANSITION_VARIANTS.collapse.enter,
     overflowY: "unset",
-    transition: {duration: transitionDuration ? transitionDuration / 1000 : 0.3},
+    transition: {duration: (transitionDuration ?? 300) / 1000},
   },
 };
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8c5975f and f2826e6.

📒 Files selected for processing (1)
  • packages/components/accordion/src/accordion-item.tsx (6 hunks)
🔇 Additional comments (5)
packages/components/accordion/src/accordion-item.tsx (5)

3-3: LGTM!

The import additions (useRef, useLayoutEffect) are appropriate for the new scroll functionality.

Also applies to: 6-6


34-35: LGTM!

The new props are clearly named and appropriately destructured.


46-46: LGTM!

The ref is correctly typed for the content wrapper div.


93-97: LGTM!

The contentRef is consistently attached across all render paths (animated vs. non-animated, keepContentMounted vs. conditional rendering), ensuring scroll functionality works in every scenario.

Also applies to: 100-106, 136-138, 157-159


165-165: LGTM!

The dependency array correctly includes transitionDuration, ensuring the animation updates when the duration prop changes.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/components/accordion/src/accordion-item.tsx (1)

46-74: Scroll-on-open implementation is solid.

The double requestAnimationFrame pattern ensures the layout has updated before scrolling, cleanup properly cancels pending callbacks, and the re-check on line 59 guards against stale refs. The use of useLayoutEffect is appropriate for synchronous DOM manipulation.

Optional observation: There's a theoretical race where if isOpen toggles very quickly (~<33ms), the inner RAF callback might execute after the accordion closes but still scroll because isOpen (line 59) is captured from the effect's closure rather than reflecting current state. This is extremely unlikely in practice and would only cause a minor visual glitch. If you want to eliminate this edge case entirely, you could store isOpen in a ref and check isOpenRef.current at line 59, but the current approach follows standard React patterns and is acceptable.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f2826e6 and 057eda1.

📒 Files selected for processing (1)
  • packages/components/accordion/src/accordion-item.tsx (6 hunks)
🔇 Additional comments (6)
packages/components/accordion/src/accordion-item.tsx (6)

3-3: LGTM! Imports are appropriate.

The new imports (useRef, useLayoutEffect) are correctly added for the scroll-on-open functionality, and the ReactNode type import is properly positioned.

Also applies to: 6-6


34-35: LGTM! New props correctly destructured.

The scrollOnOpen and transitionDuration props align with the PR objectives and are properly destructured from the hook.


91-104: LGTM! ContentRef correctly attached in non-animated branches.

Both the keepContentMounted and conditional rendering paths properly attach contentRef to the content wrapper div, enabling scrollIntoView to work when animations are disabled.


107-118: LGTM! Transition duration conversion is correct.

The milliseconds-to-seconds conversion (transitionDuration / 1000) is appropriate for Framer Motion, and the 0.3s default matches the original behavior.


134-136: LGTM! ContentRef correctly attached in animated branches.

Both animated render paths properly attach contentRef to the inner div wrapper (not the m.section), ensuring scrollIntoView works correctly across all rendering scenarios.

Also applies to: 155-157


163-163: LGTM! Dependency array correctly updated.

Adding transitionDuration to the dependency array ensures the content re-renders with updated transition variants when the duration changes.

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.

1 participant