Skip to content

ReactAriaDatePicker defaultOpen={true} incorrectly sets isPressed=true on child Button elements #8188

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
Raja-Techie-45 opened this issue May 3, 2025 · 2 comments

Comments

@Raja-Techie-45
Copy link

Raja-Techie-45 commented May 3, 2025

Provide a general summary of the issue here

When using defaultOpen={true} on the ReactAriaDatePicker component, the calendar should open by default, but child Button elements should maintain their normal state unless explicitly pressed. The isPressed state should only apply to the trigger button that opens the calendar, not all Button components within the DatePicker hierarchy.

🤔 Expected Behavior?

When using defaultOpen={true} on the ReactAriaDatePicker component, the calendar should open by default, but child Button elements should maintain their normal state unless explicitly pressed. The isPressed state should only apply to the trigger button that opens the calendar, not all Button components within the DatePicker hierarchy.

😯 Current Behavior

Setting defaultOpen={true} on ReactAriaDatePicker causes all child Button elements within the component hierarchy to receive an isPressed=true state by default, even when they're not directly related to the opening/closing mechanism of the calendar.

💁 Possible Solution

No response

🔦 Context

No response

🖥️ Steps to Reproduce

You can check the issue in below code sandbox link
https://codesandbox.io/p/sandbox/qyzpxw

Version

react-aria-components:1.8.0

What browsers are you seeing the problem on?

Chrome

If other, please specify.

No response

What operating system are you using?

Ubuntu 24.04.2 LTS

🧢 Your Company/Team

No response

🕷 Tracking Issue

No response

@Nagendra7509
Copy link

I'm experiencing the same issue in our project, and it would be great to get this fixed!

@rururux
Copy link

rururux commented May 13, 2025

Hello.

I've been looking into this issue regarding the isPressed state propagation when defaultOpen={true} is used on the DatePicker.
I had an idea for a potential solution/fix. My approach would be to refactor the DatePicker implementation to avoid using the Button Context to propagate the isPressed={state.isOpen} state to all child buttons. Instead, the trigger button component(like DatePickerTrigger) could be updated to directly access the DatePicker's state (e.g., using useDatePickerState or context) and apply the pressed state based on state.isOpen specifically to itself. This would prevent unintended isPressed states on other buttons within the DatePicker.

What do you think of this approach? If this direction seems acceptable, I would be willing to work on a pull request to implement it.

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

No branches or pull requests

3 participants