adobe / adobe/react-spectrum

DateField does not pass data attributes to the underlying dom node

Open
#7,818 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
15.9k
Forks
1.6k
Avg merge
3d 9m
Merged PRs (30d)
59

Description

### Provide a general summary of the issue here

If you pass something like a `data-testid` prop to the `DateField` component, it does not pass it through to the underlying input component, making it quite difficult to test against.

### 🤔 Expected Behavior?

In [the documentation for react-aria](https://react-spectrum.adobe.com/react-aria/testing.html#test-ids), it states that all data properties are passed through to the underlying dom node. I'd expect this would be the date for the DateField input as well.

### 😯 Current Behavior

No data properties are passed through to the underlying input.

### 💁 Possible Solution

[I think this is the line in the code that renders the underlying input](https://github.com/adobe/react-spectrum/blob/main/packages/react-aria-components/src/DateField.tsx#L267), and no props are passed to it. I'm not super familiar with this codebase, but my thought at the moment is that passing through `data-` properties to this component would fix the problem.

### 🔦 Context

Would be happy to take a stab at contributing a fix here as well, just want to make sure that this a valid bug report first!

### 🖥️ Steps to Reproduce

```tsx
import {DateField, Label, DateInput, DateSegment} from 'react-aria-components';

Birth date

{segment => }

```

And inspect the underlying input, note that the data property is not present

### Version

^1.60

### What browsers are you seeing the problem on?

Chrome

### If other, please specify.

_No response_

### What operating system are you using?

OSX

### 🧢 Your Company/Team

_No response_

### 🕷 Tracking Issue

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.