Skip to content

[Bug]: DatePicker - Unable to Create Controlled Instance of DatePicker with No Default Date #27931

@ambachtelijk

Description

@ambachtelijk

Library

React Components / v9 (@fluentui/react-components)

System Info

## Environment:
* Compat DatePicker: 0.1.2

  System (host):
    OS: Windows 10 10.0.22621
    CPU: (20) x64 12th Gen Intel(R) Core(TM) i7-12700H
    Memory: 30.98 GB / 63.69 GB
  Browsers:
    Edge: Spartan (44.22621.1702.0), Chromium (113.0.1774.50)
    Internet Explorer: 11.0.22621.1

  System (WSL2):
    OS: Linux 5.15 Ubuntu 22.04.2 LTS 22.04.2 LTS (Jammy Jellyfish)
    CPU: (20) x64 12th Gen Intel(R) Core(TM) i7-12700H
    Memory: 24.20 GB / 31.19 GB
    Container: Yes
    Shell: 5.1.16 - /bin/bash

Are you reporting Accessibility issue?

None

Reproduction

https://codesandbox.io/s/morning-surf-dnigjy?file=/src/index.tsx

Bug Description

When trying to create a controlled DatePicker component without a prefilled default date, the component either treats itself as an uncontrolled component that later changes to controlled, or the onSelectDate() and formatDate() event handlers are not triggered. This behavior inhibits our ability to use a controlled DatePicker with no prefilled date.

Steps to Reproduce:

  • Import the DatePicker from FluentUI 9.
  • Establish a DatePicker instance with no default date, and add onSelectDate() and/or formatDate() event handlers.
  • Attempt to use the DatePicker component.
  • Observe that it either acts as an uncontrolled component before switching to controlled, or that the onSelectDate() and formatDate() event handlers do not always trigger.

Expected Behavior:

The DatePicker component should not switch between uncontrolled and controlled states and the onSelectDate() and formatDate() event handlers should trigger as expected, even when there's no prefilled default date.

Actual Behavior:

The DatePicker either functions as an uncontrolled component that later becomes controlled, or the onSelectDate() and formatDate() event handlers are not triggered when there is no initial date prefilled.

Logs

No response

Requested priority

Blocking

Products/sites affected

compat datepicker

Are you willing to submit a PR to fix?

no

Validations

  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • The provided reproduction is a minimal reproducible example of the bug.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions