MudBlazor icon indicating copy to clipboard operation
MudBlazor copied to clipboard

Date/DateRange/Time-picker and Select trigger required validation when clearing input or touched

Open stiankroknes opened this issue 2 years ago • 3 comments

Description

Trigger required validation for DatePicker, TimePicker, DateRangePicker and Select when control is touched and empty (behavior of MudTextField). This pull request provides one possible solution/workaround to enable same behavior by trigger the SetTextAsync in MudInput.OnInput when text is cleared and hook up OnBlur event from the inner input (TextField, Input, RangeInput) used to trigger validation in the component, handles both EditForm and required.

Fixes #4475, #4571.

How Has This Been Tested?

Unit tests added/updated (FormTests).

Types of changes

  • [x] 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:

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

stiankroknes avatar Apr 28 '23 09:04 stiankroknes

Solves problem discussed in #6606.

stiankroknes avatar Apr 28 '23 09:04 stiankroknes

Codecov Report

:white_check_mark: All modified and coverable lines are covered by tests. :white_check_mark: Project coverage is 90.89%. Comparing base (d515b5f) to head (64861c0). :warning: Report is 1885 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #6766      +/-   ##
==========================================
+ Coverage   90.35%   90.89%   +0.53%     
==========================================
  Files         400      400              
  Lines       13681    14517     +836     
==========================================
+ Hits        12362    13195     +833     
- Misses       1319     1322       +3     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

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

codecov[bot] avatar Apr 28 '23 09:04 codecov[bot]

anyone looking into this? It's quite important for form validation logic, waiting behind this for a while now...

sirWest avatar May 29 '23 18:05 sirWest

will this ever be merged? timepicker and datepicker do still not validate on blur if startvalue is null https://try.mudblazor.com/snippet/wEwzuSuqfcZgBdWn

skyslide22 avatar Apr 06 '25 14:04 skyslide22

Closing due to age/conflicts. If anyone wants to continue working on it, please submit a new PR or issue proposal linking to this one.

danielchalmers avatar Nov 02 '25 19:11 danielchalmers