Skip to content

MudDatePicker: Fix Display of Min and Max Date and MaxValue Crash#4088

Open
mckaragoz wants to merge 4 commits intoMudBlazor:devfrom
mckaragoz:DatePickerMinMaxDate
Open

MudDatePicker: Fix Display of Min and Max Date and MaxValue Crash#4088
mckaragoz wants to merge 4 commits intoMudBlazor:devfrom
mckaragoz:DatePickerMinMaxDate

Conversation

@mckaragoz
Copy link
Member

Description

Fixes #4087.

Fix min and max date to working properly on OpenTo.Month and OpenTo.Year.

How Has This Been Tested?

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
20220302_224304.mp4

Checklist:

  • The PR is submitted to the correct branch (dev).
  • My code follows the code style of this project.
  • I've added relevant tests.

@codecov
Copy link

codecov bot commented Mar 2, 2022

Codecov Report

❌ Patch coverage is 84.74576% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.13%. Comparing base (dd2b8c1) to head (044c600).
⚠️ Report is 2370 commits behind head on dev.

Files with missing lines Patch % Lines
...r/Components/DatePicker/MudBaseDatePicker.razor.cs 83.33% 8 Missing ⚠️
...c/MudBlazor/Components/DatePicker/MudDatePicker.cs 50.00% 1 Missing ⚠️

❌ Your patch check has failed because the patch coverage (84.74%) is below the target coverage (100.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #4088      +/-   ##
==========================================
- Coverage   91.22%   91.13%   -0.09%     
==========================================
  Files         359      359              
  Lines       12434    12482      +48     
==========================================
+ Hits        11343    11376      +33     
- Misses       1091     1106      +15     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Member

@JonBunator JonBunator left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my opinion, it's way better UX if the buttons are either disabled or completely hidden (arrows).
It creates a false impression that something should happen when you get click feedback, but nothing happens.

@JonBunator JonBunator added bug Unexpected behavior or functionality not working as intended needs: tests A maintainer has explicitly asked for associated test cases to be added to this pull request labels Mar 13, 2022
@mckaragoz
Copy link
Member Author

mckaragoz commented Mar 23, 2022

So here the last news:

  • Only years which between min and max show
  • Year navigate button disappear in month view if they not inside min and max
  • Mont navigate button disappear in day view if they not inside min and max

@JonBunator i added to show/hide buttons related to min max date, thats a great suggestion.

20220323_213659.mp4

If its done, i will prepare tests and then merge.

@mckaragoz mckaragoz changed the title DatePicker: Fix Min and Max Date Implementations DatePicker: Fix Min and Max Date Visual Implementations Mar 23, 2022
@mckaragoz mckaragoz changed the title DatePicker: Fix Min and Max Date Visual Implementations DatePicker: Fix Min and Max Date Visual Implementations And Fix MaxValue Exceed Crash Bug Mar 24, 2022
@mckaragoz
Copy link
Member Author

mckaragoz commented Mar 24, 2022

So here is the last news. I think its solid now.

This is the last shape of when we reach MaxDate, next button disappears (same for the month view) and exceed days disabled. We have the reversed version for the MinDate.

Ekran görüntüsü 2022-03-24 174405

In current, DatePicker crashes when we try to go beyond to the max value, its fixed now. (Next button is hidden now, yes, but also fix the code so if there is even a button, it didn't give exception when you click it.) And also we hide buttons for the DateTime.MinValue and DateTime.MaxValue

20220324_172455.mp4

And what about change date programmatically? Now we disabled that now date changing more than max and less then min have no effect. (This example shows that Min-Max picker value didn't changed although they are all connected by the same value)

20220324_173344.mp4

So if its good, there are only tests missing.

}
}

:not(.mud-picker-hidden) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Garderoben i deleted this because prev button has not this kind of style and this !important prevents all visibility styling. We already fix the max date problem so i think this is not necessary. Could you look at this?

return Culture.Calendar.GetDayOfMonth(date);
}

private void UpdateMinMaxDateExceedStatus()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@henon could you look at this? This method runs onafterrender(firstrender is true) and each time PickerMonth is changed. Is it simple enough?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually not a good way of doing it. Keeping state in private variables is always more error prone than just calculating that state. Instead you can add four private functions that calculate these states.

@mikes-gh mikes-gh changed the title DatePicker: Fix Min and Max Date Visual Implementations And Fix MaxValue Exceed Crash Bug MudDatePicker: Fix Min and Max Date Visual Implementations And Fix MaxValue Exceed Crash Bug Sep 13, 2022
@henon henon changed the title MudDatePicker: Fix Min and Max Date Visual Implementations And Fix MaxValue Exceed Crash Bug MudDatePicker: Fix Display of Min and Max Date and MaxValue Crash Dec 10, 2022
Copy link
Contributor

@henon henon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use calculated state instead of stored state. Then tests, then this can be merged.

return Culture.Calendar.GetDayOfMonth(date);
}

private void UpdateMinMaxDateExceedStatus()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually not a good way of doing it. Keeping state in private variables is always more error prone than just calculating that state. Instead you can add four private functions that calculate these states.

@mikes-gh
Copy link
Contributor

Hi @mckaragoz Will you complete this or should we close.?

@mckaragoz
Copy link
Member Author

Hi @mckaragoz Will you complete this or should we close.?

This one is nearly ready, i can do the remainings in this week

@Anu6is
Copy link
Contributor

Anu6is commented Jan 23, 2025

@mckaragoz any intentions of reviving this or should this be closed?

@mckaragoz
Copy link
Member Author

Wow does it still remain? I remembered that something was merged about max value. We should check

@Anu6is
Copy link
Contributor

Anu6is commented Jan 23, 2025

The link provided in the issue still breaks, yeah.
https://try.mudblazor.com/snippet/cOcQuHEmgGEoyHfi

@github-actions github-actions bot added the stale Issue or PR has had no activity and is subject to automatic closure if not updated label Jul 31, 2025
@github-actions
Copy link

Hi, this pull request hasn't had activity in a while and has been marked as stale.

Please reply if you're still working on it!

@mckaragoz
Copy link
Member Author

Hi

@github-actions github-actions bot added awaiting triage Needs maintainer review or assistance and removed stale Issue or PR has had no activity and is subject to automatic closure if not updated labels Aug 3, 2025
@danielchalmers danielchalmers removed the awaiting triage Needs maintainer review or assistance label Aug 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Unexpected behavior or functionality not working as intended needs: tests A maintainer has explicitly asked for associated test cases to be added to this pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

set MaxDate to current month is not working

6 participants