Skip to content

MudTimePicker: Fix hour not updating when changed more than once (#7483)#7517

Merged
henon merged 3 commits intoMudBlazor:devfrom
igotinfected:fix/time-picker-hours-not-updating-when-changed-twice
Sep 18, 2023
Merged

MudTimePicker: Fix hour not updating when changed more than once (#7483)#7517
henon merged 3 commits intoMudBlazor:devfrom
igotinfected:fix/time-picker-hours-not-updating-when-changed-twice

Conversation

@igotinfected
Copy link
Member

Description

Fixes: #7483

As described in the original issue: when changing the hour more than once, the hour is not immediately updated, only when the minutes are updated.

I removed a check in the OnMouseUp function (that to me does not seem necessary, maybe a leftover from previous implementations?) that stopped the hour from updating.

How Has This Been Tested?

Visually verified + bUnit-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)

Checklist:

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

@github-actions github-actions bot added bug Unexpected behavior or functionality not working as intended PR: needs review labels Sep 16, 2023
@igotinfected
Copy link
Member Author

FYI -- had to add .Click()s to some of the tests because of the changes to OnMouseUp, as far as I can tell this is the right way to do it (mousedown -> mouseup -> click -> action).

@ScarletKuro ScarletKuro requested a review from henon September 16, 2023 18:26
@codecov
Copy link

codecov bot commented Sep 16, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (9a6a0d5) 90.56% compared to head (5b90d71) 90.56%.

Additional details and impacted files
@@           Coverage Diff           @@
##              dev    #7517   +/-   ##
=======================================
  Coverage   90.56%   90.56%           
=======================================
  Files         427      427           
  Lines       15210    15213    +3     
=======================================
+ Hits        13775    13778    +3     
  Misses       1435     1435           
Files Changed Coverage Δ
...lazor/Components/TimePicker/MudTimePicker.razor.cs 99.67% <100.00%> (+<0.01%) ⬆️

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

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.

Thank you for your contribution. Please address the following issues:

The MouseUp logic looks fishy and probably needs correction. The unit tests probably too.

@igotinfected
Copy link
Member Author

igotinfected commented Sep 18, 2023

Thank you for your contribution. Please address the following issues:

The MouseUp logic looks fishy and probably needs correction. The unit tests probably too.

@henon thank you for the feedback and the doubts -- you were right, my implementation was incorrect and based on false assumptions.

My initial assumption was that the OnMouseUp was forcing the view for hours to change to minutes for no reason at all, which isn't the case. It handles switching from hours to minutes on mouse up if the value has changed, which is expected behaviour by existing unit tests.

To avoid messing around with those, the "new" implementation verifies, when a click event is received, if the hour value has changed, and updates the time accordingly.

I also discovered an edge case where switching back to the _initialHour would not update the hour despite the fix, so I introduced a _lastSelectedHour field for a more accurate check (tested against with a specific unit test case).

Edit: I don't mind digging deeper if need be, don't hold back :)

@henon henon merged commit 987dca7 into MudBlazor:dev Sep 18, 2023
@henon
Copy link
Contributor

henon commented Sep 18, 2023

Looking good now, don't worry about it, I make plenty of similar mistakes myself when the day is long.
Thanks @igotinfected !

@igotinfected igotinfected deleted the fix/time-picker-hours-not-updating-when-changed-twice branch September 19, 2023 19:07
ilovepilav pushed a commit to ilovepilav/MudBlazor that referenced this pull request Nov 25, 2023
…Blazor#7483) (MudBlazor#7517)

* MudTimePicker: Fix hour not updating when changed more than once

Fixes: MudBlazor#7483
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MudTimePicker hours not updating after switching back and selecting a different hour

3 participants