Skip to content

"milliseconds" granularity for DateField and TimeField #6415

Open
@andrei-zz

Description

@andrei-zz

Provide a general summary of the feature here

TimeField and DateField should support "millisecond" granularity.

🤔 Expected Behavior?

When passing granularity="millisecond" to <TimeField />, the TimeField should show a DateSegment that has current millisecond value and allow users to edit the millisecond value of the value prop.

😯 Current Behavior

The defined TypeScript type of the granularity prop doesn't even have "millisecond" option. (removed in #3435)

💁 Possible Solution

I'm not sure how DateField and TimeField work under the hood. I read useTimeField but still don't know how to implement the described functionalities by myself. Currently I render a separate NumberField to allow users to edit the millisecond field of the same value passed to TimeField (see "Examples" section). I.e.,

<NumberField
  label="Millisecond"
  value={myCalendarDateTimeValue.millisecond}
  onChange={(value) =>
    setMyCalendarDateTimeValue((prev) =>
      prev.set({ millisecond: value })
    )
  }
  minValue={0}
  maxValue={999}
/>

🔦 Context

I am working on a time calculator project using combination of date and time input fields from 'react-aria-components'. The proposed feature is important for my project since I wanted to support millisecond level calculation. I saw #3117 and #3435, what are the challenges you faced in implementing the feature. I am willing to contribute but will need some guidance.

💻 Examples

Workaround described above
https://stackblitz.com/edit/vitejs-vite-ezvnrt?file=src%2FApp.tsx

🧢 Your Company/Team

No response

🕷 Tracking Issue

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions