Skip to content

fixes for uncontrolled to controlled error and other small console warns #1220

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

GoldGroove06
Copy link
Collaborator

@GoldGroove06 GoldGroove06 commented Jul 17, 2025

closes #1187

Summary by CodeRabbit

  • New Features

    • Accordion and Disclosure items now update their open/closed state in real time based on user interactions.
  • Bug Fixes

    • Improved consistency of open state handling in Accordion and Disclosure components.
  • Tests

    • Updated tests to simulate user interactions instead of relying on manual focus or prop changes.
    • Adjusted test logic for Collapsible components to better reflect real-world usage.
    • Wrapped focus and event calls in tests within React's act() for more reliable test execution.
  • Refactor

    • Standardized data attribute naming in the Callout component for consistency.
    • Updated Dialog overlay styling to use Tailwind CSS classes for better maintainability.

Copy link
Contributor

coderabbitai bot commented Jul 17, 2025

Walkthrough

The changes update AccordionItem and DisclosureItem components to synchronize their open state with the CollapsiblePrimitive.Root using the onOpenChange handler. Test files for Accordion and Collapsible are adjusted to reflect these changes, and a minor update is made to the CalloutRoot component regarding data attribute generation. Additionally, a story file for DialogPrimitive was updated to replace inline styles with Tailwind CSS classes. A syntax fix was applied to RadioGroupPrimitiveRoot.

Changes

File(s) Change Summary
src/components/ui/Accordion/fragments/AccordionItem.tsx
src/components/ui/Disclosure/fragments/DisclosureItem.tsx
Added onOpenChange handler to synchronize local isOpen state with CollapsiblePrimitive.Root open state.
src/components/ui/Accordion/tests/Accordion.test.tsx
src/core/primitives/Collapsible/tests/Collapsible.test.tsx
Wrapped .focus() and fireEvent calls in act(); changed test to simulate user interaction instead of manual rerender.
src/components/ui/Callout/fragments/CalloutRoot.tsx Changed argument to useCreateDataAttribute from 'Callout' to 'callout'.
src/core/primitives/Dialog/stories/DialogPrimitive.stories.tsx Replaced inline styles with Tailwind CSS utility classes for overlay opacity and background color.
src/core/primitives/RadioGroup/fragments/RadioGroupPrimitiveRoot.tsx Fixed syntax error by adding missing closing brace in object literal.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant AccordionItem
    participant CollapsiblePrimitiveRoot

    User->>CollapsiblePrimitiveRoot: Triggers open/close (click, keyboard)
    CollapsiblePrimitiveRoot->>AccordionItem: Calls onOpenChange(newState)
    AccordionItem->>AccordionItem: setIsOpen(newState)
Loading
sequenceDiagram
    participant User
    participant DisclosureItem
    participant CollapsiblePrimitiveRoot

    User->>CollapsiblePrimitiveRoot: Triggers open/close (click, keyboard)
    CollapsiblePrimitiveRoot->>DisclosureItem: Calls onOpenChange(newState)
    DisclosureItem->>DisclosureItem: setIsOpen(newState)
Loading

Estimated code review effort

3 (30–60 minutes)

Possibly related PRs

Suggested labels

automerge

Suggested reviewers

  • kotAPI

Poem

In the garden of code, where components bloom,
Accordions and Disclosures now open in tune.
No warnings disturb this peaceful domain,
As state and events are perfectly in train.
A hop, a click, a gentle change—
All controlled, nothing strange!
🐇✨

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

npm error Exit handler never called!
npm error This is an error with npm itself. Please report this error at:
npm error https://github.com/npm/cli/issues
npm error A complete log of this run can be found in: /.npm/_logs/2025-07-21T08_16_40_536Z-debug-0.log


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between adceabf and b8f5188.

📒 Files selected for processing (2)
  • src/components/ui/Accordion/tests/Accordion.test.tsx (2 hunks)
  • src/core/primitives/RadioGroup/fragments/RadioGroupPrimitiveRoot.tsx (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • src/core/primitives/RadioGroup/fragments/RadioGroupPrimitiveRoot.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/components/ui/Accordion/tests/Accordion.test.tsx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build
✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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: 2

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0b43163 and c0139c1.

📒 Files selected for processing (5)
  • src/components/ui/Accordion/fragments/AccordionItem.tsx (1 hunks)
  • src/components/ui/Accordion/tests/Accordion.test.tsx (0 hunks)
  • src/components/ui/Callout/fragments/CalloutRoot.tsx (1 hunks)
  • src/components/ui/Disclosure/fragments/DisclosureItem.tsx (1 hunks)
  • src/core/primitives/Collapsible/tests/Collapsible.test.tsx (1 hunks)
💤 Files with no reviewable changes (1)
  • src/components/ui/Accordion/tests/Accordion.test.tsx
🧰 Additional context used
🧠 Learnings (5)
📓 Common learnings
Learnt from: kotAPI
PR: rad-ui/ui#640
File: .github/workflows/build-rad-ui.yml:5-5
Timestamp: 2024-12-14T02:25:41.034Z
Learning: In the `rad-ui/ui` repository, the `security-fixes` branch only updates dependencies, so linting and Chromatic workflows are not required for this branch.
Learnt from: kotAPI
PR: rad-ui/ui#1031
File: src/components/ui/Accordion/fragments/AccordionRoot.tsx:41-44
Timestamp: 2025-04-07T04:38:34.864Z
Learning: The Accordion component in rad-ui/ui supports both controlled and uncontrolled modes through props like `value`, `defaultValue`, and `onValueChange`. When implementing controlled components, remember to: 1) Initialize state from defaultValue, 2) Update internal state when value changes (controlled mode), 3) Call onValueChange callback, and 4) Prevent internal state updates when in controlled mode.
Learnt from: decipher-cs
PR: rad-ui/ui#417
File: src/components/ui/Dropdown/Dropdown.stories.tsx:43-50
Timestamp: 2024-12-12T08:34:33.079Z
Learning: Ensure to verify existing ARIA attributes in components before suggesting additions during code reviews, especially in the `Dropdown.Trigger` component in `src/components/ui/Dropdown/Dropdown.stories.tsx`.
Learnt from: kotAPI
PR: rad-ui/ui#576
File: src/core/primitives/Toggle/index.tsx:15-22
Timestamp: 2024-11-24T06:43:42.194Z
Learning: In the `TogglePrimitive` component (`src/core/primitives/Toggle/index.tsx`), when the component becomes controlled, it's acceptable to not sync the internal `isPressed` state with the external `pressed` prop.
src/components/ui/Callout/fragments/CalloutRoot.tsx (2)
Learnt from: decipher-cs
PR: rad-ui/ui#417
File: src/components/ui/Dropdown/Dropdown.stories.tsx:43-50
Timestamp: 2024-12-12T08:34:33.079Z
Learning: Ensure to verify existing ARIA attributes in components before suggesting additions during code reviews, especially in the `Dropdown.Trigger` component in `src/components/ui/Dropdown/Dropdown.stories.tsx`.
Learnt from: decipher-cs
PR: rad-ui/ui#417
File: src/components/ui/Dropdown/Dropdown.tsx:0-0
Timestamp: 2024-12-12T08:22:59.375Z
Learning: The `Dropdown.Trigger` component is customizable and needs to be used with `Dropdown.Root`.
src/components/ui/Accordion/fragments/AccordionItem.tsx (3)
Learnt from: kotAPI
PR: rad-ui/ui#1031
File: src/components/ui/Accordion/fragments/AccordionRoot.tsx:41-44
Timestamp: 2025-04-07T04:38:34.864Z
Learning: The Accordion component in rad-ui/ui supports both controlled and uncontrolled modes through props like `value`, `defaultValue`, and `onValueChange`. When implementing controlled components, remember to: 1) Initialize state from defaultValue, 2) Update internal state when value changes (controlled mode), 3) Call onValueChange callback, and 4) Prevent internal state updates when in controlled mode.
Learnt from: kotAPI
PR: rad-ui/ui#576
File: src/core/primitives/Toggle/index.tsx:15-22
Timestamp: 2024-11-24T06:43:42.194Z
Learning: In the `TogglePrimitive` component (`src/core/primitives/Toggle/index.tsx`), when the component becomes controlled, it's acceptable to not sync the internal `isPressed` state with the external `pressed` prop.
Learnt from: decipher-cs
PR: rad-ui/ui#417
File: src/components/ui/Dropdown/Dropdown.stories.tsx:43-50
Timestamp: 2024-12-12T08:34:33.079Z
Learning: Ensure to verify existing ARIA attributes in components before suggesting additions during code reviews, especially in the `Dropdown.Trigger` component in `src/components/ui/Dropdown/Dropdown.stories.tsx`.
src/components/ui/Disclosure/fragments/DisclosureItem.tsx (3)
Learnt from: kotAPI
PR: rad-ui/ui#576
File: src/core/primitives/Toggle/index.tsx:15-22
Timestamp: 2024-11-24T06:43:42.194Z
Learning: In the `TogglePrimitive` component (`src/core/primitives/Toggle/index.tsx`), when the component becomes controlled, it's acceptable to not sync the internal `isPressed` state with the external `pressed` prop.
Learnt from: decipher-cs
PR: rad-ui/ui#417
File: src/components/ui/Dropdown/Dropdown.stories.tsx:43-50
Timestamp: 2024-12-12T08:34:33.079Z
Learning: Ensure to verify existing ARIA attributes in components before suggesting additions during code reviews, especially in the `Dropdown.Trigger` component in `src/components/ui/Dropdown/Dropdown.stories.tsx`.
Learnt from: kotAPI
PR: rad-ui/ui#1031
File: src/components/ui/Accordion/fragments/AccordionRoot.tsx:41-44
Timestamp: 2025-04-07T04:38:34.864Z
Learning: The Accordion component in rad-ui/ui supports both controlled and uncontrolled modes through props like `value`, `defaultValue`, and `onValueChange`. When implementing controlled components, remember to: 1) Initialize state from defaultValue, 2) Update internal state when value changes (controlled mode), 3) Call onValueChange callback, and 4) Prevent internal state updates when in controlled mode.
src/core/primitives/Collapsible/tests/Collapsible.test.tsx (2)
Learnt from: kotAPI
PR: rad-ui/ui#576
File: src/core/primitives/Toggle/index.tsx:15-22
Timestamp: 2024-11-24T06:43:42.194Z
Learning: In the `TogglePrimitive` component (`src/core/primitives/Toggle/index.tsx`), when the component becomes controlled, it's acceptable to not sync the internal `isPressed` state with the external `pressed` prop.
Learnt from: decipher-cs
PR: rad-ui/ui#417
File: src/components/ui/Dropdown/Dropdown.stories.tsx:43-50
Timestamp: 2024-12-12T08:34:33.079Z
Learning: Ensure to verify existing ARIA attributes in components before suggesting additions during code reviews, especially in the `Dropdown.Trigger` component in `src/components/ui/Dropdown/Dropdown.stories.tsx`.
🧬 Code Graph Analysis (1)
src/components/ui/Callout/fragments/CalloutRoot.tsx (1)
src/core/hooks/createDataAttribute/index.ts (1)
  • useCreateDataAttribute (10-25)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build
🔇 Additional comments (2)
src/components/ui/Callout/fragments/CalloutRoot.tsx (1)

23-23: Good normalization of data attribute prefix to lowercase.

This change standardizes the data attribute prefix from 'Callout' to 'callout', which will generate consistent lowercase data attributes (e.g., data-callout-variant instead of data-Callout-variant). This appears to be part of a broader consistency effort across the component library.

src/core/primitives/Collapsible/tests/Collapsible.test.tsx (1)

21-24: Excellent improvement to test event-driven behavior.

The test now simulates actual user interaction by clicking the trigger element instead of manually rerendering with props. This better reflects real usage patterns and validates that the collapsible primitive properly handles user events and updates its data-state attribute accordingly.

Also applies to: 28-28

@@ -38,6 +38,7 @@ const AccordionItem: React.FC<AccordionItemProps> = ({ children, value, classNam
<AccordionItemContext.Provider value={{ itemValue, setItemValue, disabled }}>
<CollapsiblePrimitive.Root
open={isOpen}
onOpenChange={setIsOpen}
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Verify state synchronization between collapsible primitive and accordion context.

Adding onOpenChange={setIsOpen} creates a two-way binding with the collapsible primitive, but there's a potential conflict with the useEffect on lines 24-26 that syncs isOpen with activeItems from the accordion context.

When a user triggers the collapsible to open/close, onOpenChange will update the local isOpen state, but if the accordion context's activeItems doesn't reflect this change, the useEffect might override the user's action.


🏁 Script executed:

#!/bin/bash
# Description: Check how AccordionRoot manages activeItems state and if it responds to individual item changes
# Expected: Find onValueChange or similar handlers in AccordionRoot that update activeItems

ast-grep --pattern 'const AccordionRoot = $_' -A 50

Length of output: 4072


🏁 Script executed:

#!/bin/bash
# Inspect AccordionItem around onOpenChange and state management
rg -n -C5 "AccordionItem" -n src/components/ui/Accordion/fragments/AccordionItem.tsx
rg -n -C5 "onOpenChange" src/components/ui/Accordion/fragments/AccordionItem.tsx

Length of output: 2320


🏁 Script executed:

#!/bin/bash
# Check for useEffect syncing isOpen with activeItems in AccordionItem
rg -n "useEffect" -C5 src/components/ui/Accordion/fragments/AccordionItem.tsx

Length of output: 1123


Ensure AccordionItem updates accordion context instead of only local state

The onOpenChange={setIsOpen} handler only updates the local isOpen flag, but never calls setActiveItems on the parent AccordionContext. As a result, your useEffect that syncs isOpen from activeItems will immediately override any local toggle. You need to:

• Destructure setActiveItems and openMultiple from AccordionContext.
• Replace the local setIsOpen callback with a handler that adds or removes itemValue from activeItems.

Affected locations in src/components/ui/Accordion/fragments/AccordionItem.tsx:

  • Line 21: Update context destructuring.
  • Lines 40–41: Replace onOpenChange={setIsOpen}.

Suggested diff:

--- a/src/components/ui/Accordion/fragments/AccordionItem.tsx
+++ b/src/components/ui/Accordion/fragments/AccordionItem.tsx
@@ 21,1 +21,1 @@
-   const { rootClass, activeItems, transitionDuration, transitionTimingFunction } = useContext(AccordionContext);
+   const { rootClass, activeItems, setActiveItems, openMultiple, transitionDuration, transitionTimingFunction } = useContext(AccordionContext);
@@ 39,2 +39,11 @@
     <CollapsiblePrimitive.Root
-        open={isOpen}
-        onOpenChange={setIsOpen}
+        open={isOpen}
+        onOpenChange={(open) => {
+          if (open) {
+            setActiveItems(openMultiple
+              ? [...activeItems, itemValue]
+              : [itemValue]
+            );
+          } else {
+            setActiveItems(activeItems.filter((v) => v !== itemValue));
+          }
+        }}

This ensures toggles update the accordion’s activeItems, and your useEffect will correctly derive isOpen from that shared state.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
onOpenChange={setIsOpen}
// Line 21: include setActiveItems and openMultiple from context
const {
rootClass,
activeItems,
setActiveItems,
openMultiple,
transitionDuration,
transitionTimingFunction,
} = useContext(AccordionContext);
// …
<CollapsiblePrimitive.Root
open={isOpen}
onOpenChange={(open) => {
if (open) {
setActiveItems(
openMultiple
? [...activeItems, itemValue]
: [itemValue]
);
} else {
setActiveItems(
activeItems.filter((v) => v !== itemValue)
);
}
}}
>
{/* … */}
</CollapsiblePrimitive.Root>
🤖 Prompt for AI Agents
In src/components/ui/Accordion/fragments/AccordionItem.tsx around lines 21 and
40-41, the onOpenChange handler currently only updates local isOpen state and
does not update the accordion context's activeItems. To fix this, destructure
setActiveItems and openMultiple from AccordionContext at line 21, then replace
onOpenChange={setIsOpen} with a handler that updates activeItems by adding or
removing itemValue accordingly. This will ensure the accordion context state is
updated and the useEffect syncing isOpen from activeItems works correctly.

@@ -32,6 +32,7 @@ const DisclosureItem = ({ children, className = '', value }:DisclosureItemProps)

<CollapsiblePrimitive.Root
open={isOpen}
onOpenChange={setIsOpen}
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Verify state synchronization between collapsible primitive and disclosure context.

Similar to the AccordionItem, adding onOpenChange={setIsOpen} creates a potential conflict with the useEffect on lines 20-22 that syncs isOpen with activeItem from the disclosure context.

When the collapsible primitive changes state, onOpenChange will update the local isOpen state, but if the disclosure context's activeItem doesn't reflect this change, the useEffect might override the user's action.


🏁 Script executed:

#!/bin/bash
# Description: Check how DisclosureRoot manages activeItem state and if it responds to individual item changes
# Expected: Find state management logic in DisclosureRoot that updates activeItem

ast-grep --pattern 'const DisclosureRoot = $_' -A 50

Length of output: 3378


🏁 Script executed:

#!/bin/bash
# Inspect DisclosureItem and AccordionItem implementations for state sync patterns

# Locate and display DisclosureItem.tsx
echo "=== DisclosureItem.tsx ==="
fd DisclosureItem.tsx -t f
cat src/components/ui/Disclosure/fragments/DisclosureItem.tsx

# Locate and display AccordionItem.tsx for comparison
echo -e "\n=== AccordionItem.tsx ==="
fd AccordionItem.tsx -t f
cat src/components/ui/Accordion/fragments/AccordionItem.tsx

Length of output: 4404


🏁 Script executed:

#!/bin/bash
# Inspect DisclosureTrigger and DisclosureContent implementations for context interactions

echo "=== DisclosureTrigger.tsx ==="
fd DisclosureTrigger.tsx -t f
cat src/components/ui/Disclosure/fragments/DisclosureTrigger.tsx

echo -e "\n=== DisclosureContent.tsx ==="
fd DisclosureContent.tsx -t f
cat src/components/ui/Disclosure/fragments/DisclosureContent.tsx

Length of output: 2932


Remove local onOpenChange in favor of context-driven state

The onOpenChange={setIsOpen} on line 35 in DisclosureItem creates a one-way update to the local isOpen flag—but the disclosure context’s activeItem never changes, so your useEffect immediately resets isOpen to match activeItem. That conflicts with user actions. Since the trigger already calls setActiveItem, you should drive open/closed purely from context:

• File: src/components/ui/Disclosure/fragments/DisclosureItem.tsx
– Remove the onOpenChange={setIsOpen} prop on <CollapsiblePrimitive.Root>
– (Optionally) drop the isOpen/setIsOpen local state entirely and read open={activeItem === itemValue} directly

Suggested diff snippet:

--- a/src/components/ui/Disclosure/fragments/DisclosureItem.tsx
+++ b/src/components/ui/Disclosure/fragments/DisclosureItem.tsx
@@ -33,7 +33,7 @@
           <CollapsiblePrimitive.Root
-            open={isOpen}
-            onOpenChange={setIsOpen}
+            open={activeItem === itemValue}
             asChild
           >
🤖 Prompt for AI Agents
In src/components/ui/Disclosure/fragments/DisclosureItem.tsx at line 35, remove
the onOpenChange={setIsOpen} prop from the CollapsiblePrimitive.Root component
to avoid conflicting local state updates. Instead, eliminate the local isOpen
and setIsOpen state variables and directly control the open state by comparing
activeItem from context with itemValue, passing open={activeItem === itemValue}
to CollapsiblePrimitive.Root.

@@ -69,7 +69,6 @@ describe('Accordion Component', () => {
test('displays content when item is focused and enter is pressed', () => {
render(<TestAccordion />);
const item1Trigger = screen.getByText('Item 1');
item1Trigger.focus();
Copy link
Collaborator

Choose a reason for hiding this comment

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

why? this doesnt make sense

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

making it focus gives error from rovingFocus in tests

image

making it focused doesnt test anything. The test makes it focused and then fires click event.

Copy link
Collaborator

Choose a reason for hiding this comment

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

This is asking you to wrap the test inside an act function

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

i'll make the 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.

React Warnings and Component Issues
2 participants