Skip to content

fix: Year not enabled in year range view in DatePicker when Jan1 of a year is disabled #3348

@DanUmstattd-USDA

Description

@DanUmstattd-USDA

🐛 Bug Report

I am using the date picker and providing a list of dates to be enabled, but the list does not include Jan 1 of any given year then the year is disabled in Calendar View Years.

💻 Repro or Code Sample

<FluentDatePicker Label="Date" @bind-Value="filterDate" View="@CalendarViews.Months" DisabledDateFunc="@DisabledDate" />
private bool DisabledDate(DateTime date) => !surveyDates.Any(d => d.SurveyDate == new DateOnly(date.Year, date.Month, date.Day));

🤔 Expected Behavior

I would expect that if any date within the year or the month would enable that given month or year.

😯 Current Behavior

When viewing Months view since the dates available include the first of the month it is visible. But when viewing Years view since Jan 1 is not enabled, the Year shows disabled.

Month View:

Image

Year View:

Image

💁 Possible Solution

It would be best that the disabling of the month level and the year level view is determined based on if there is any date enabled within a list of enabled dates. Whether that is changing to reference a list of dates enabled. Or have a way to determine which view of the date being passed to the DisabledDateFunc. Another would be to allow us to control which views are available and still allow the default view to be set.

🔦 Context

This affects us being able to use the DatePicker if we need to disable dates that are not the 1st of the month or year. We will have to use a dropdown instead of a datepicker. This is a filter input for initializing population of a datagrid from the database.

🌍 Your Environment

  • OS & Device: MacOS, iOS, Windows, Linux] on [iPhone 7, PC
  • Browser: Microsoft Edge, Google Chrome, Apple Safari, Mozilla FireFox
  • .NET and Fluent UI Blazor library Version: Dotnet 8.0.x and 4.11.3

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions