fluentui icon indicating copy to clipboard operation
fluentui copied to clipboard

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

Open ehmPlankje opened this issue 2 years ago • 1 comments
trafficstars

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

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

ehmPlankje avatar May 22 '23 10:05 ehmPlankje

@sopranopillow see also https://github.com/microsoft/fluentui/issues/27955#issuecomment-1559595354.

layershifter avatar May 24 '23 08:05 layershifter

:tada:This issue was addressed in #28056, which has now been successfully released as @fluentui/[email protected].:tada:

Handy links:

msft-fluent-ui-bot avatar Jun 21 '23 07:06 msft-fluent-ui-bot

:tada:This issue was addressed in #28056, which has now been successfully released as @fluentui/[email protected].:tada:

Handy links:

msft-fluent-ui-bot avatar Jun 21 '23 07:06 msft-fluent-ui-bot