Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Masking: Add DateMask and support Mask in DatePicker #3874

Merged
merged 5 commits into from Feb 11, 2022
Merged

Conversation

henon
Copy link
Collaborator

@henon henon commented Feb 3, 2022

closes #3892

Adds a date mask algorithm that works exactly like Cleave.js's date mask.

How Has This Been Tested?

unit

Types of changes

  • New feature (non-breaking change which adds functionality)

Checklist:

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

@henon henon requested a review from mckaragoz February 3, 2022 13:45
@henon henon added the enhancement New feature or request label Feb 3, 2022
@codecov
Copy link

codecov bot commented Feb 3, 2022

Codecov Report

Merging #3874 (f559c77) into dev (7b360dd) will increase coverage by 0.07%.
The diff coverage is 93.12%.

Impacted file tree graph

@@            Coverage Diff             @@
##              dev    #3874      +/-   ##
==========================================
+ Coverage   91.04%   91.12%   +0.07%     
==========================================
  Files         350      351       +1     
  Lines       11462    11603     +141     
==========================================
+ Hits        10436    10573     +137     
- Misses       1026     1030       +4     
Impacted Files Coverage Δ
src/MudBlazor/Utilities/MaskAlgorithms/DateMask.cs 92.24% <92.24%> (ø)
src/MudBlazor/Components/Picker/MudPicker.razor.cs 97.67% <95.00%> (+0.07%) ⬆️
src/MudBlazor/Components/Mask/MudMask.razor.cs 93.43% <100.00%> (+3.22%) ⬆️
src/MudBlazor/Components/Picker/MudPicker.razor 86.95% <100.00%> (ø)
.../MudBlazor/Utilities/MaskAlgorithms/PatternMask.cs 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7b360dd...f559c77. Read the comment docs.

@henon henon changed the title Add DateMask Masking: Add DateMask Feb 3, 2022
@henon henon requested a review from HClausing February 3, 2022 19:36
mask.CaretPos = 4;
mask.ToString().Should().Be("12/3|1/99");
mask.Delete();
mask.ToString().Should().Be("12/3|1/9");
Copy link

Choose a reason for hiding this comment

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

I'm not sure about the following use case:

  1. Write 12/3|1/99
  2. I wanted to type 12/30/99 so I press delete
  3. Now I have 12/3|1/9 so I press 0.
  4. But the year is now 12/30|/19

Maybe the mask should autocorrect on blur?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The same happens here: https://nosir.github.io/cleave.js/ in the date example, but I agree that this is not exactly desirable behavior.

Some of the autocorrection while typing is pretty useful though. like typing 5599 results in 05/05/99.

So maybe this kind of autocorrection should be applied only when typing at the end of the text?

Copy link

@ghost ghost Feb 7, 2022

Choose a reason for hiding this comment

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

@henon Autocorrection is very cool and time saving.

What about theses rules?

  1. When typing, autocorrect if the preceding date part is completed or constrained.
  2. When pressing delete or backspace, don't autocorrect.
  3. When the mask is fully filled, autocorrect the whole date.

Scenarios :

  • With a mask MM/dd/yyyy
    • When pressing 5, autocorrect to 05.
    • Press 4, autocorrect to 04
    • Press 2018
  • With a mask MM/dd/yy
    • Enter 10420 gives 10/04/20
    • Move cursor 10/0|4/20
    • Press delete
    • Press backspace
    • Type 12
    • It gives 10/12/20

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@naster01 I agree and I plan to do this in a followup PR.

@Mr-Technician
Copy link
Member

This should close #3892

@henon henon changed the title Masking: Add DateMask Masking: Add DateMask and support Mask in DatePicker Feb 11, 2022
@henon henon merged commit d381e77 into MudBlazor:dev Feb 11, 2022
@henon henon added this to the 6.0.7 milestone Feb 11, 2022
jammerware pushed a commit to jammerware/MudBlazor that referenced this pull request Sep 20, 2022
* DateMask

* Fixed mask examples for small screens

* Add datemask example to docs

* MudPicker: support Masking

* Docs: DatePicker masking examples
jammerware pushed a commit to jammerware/MudBlazor that referenced this pull request Sep 20, 2022
* DateMask

* Fixed mask examples for small screens

* Add datemask example to docs

* MudPicker: support Masking

* Docs: DatePicker masking examples
jammerware pushed a commit to jammerware/MudBlazor that referenced this pull request Sep 20, 2022
* DateMask

* Fixed mask examples for small screens

* Add datemask example to docs

* MudPicker: support Masking

* Docs: DatePicker masking examples
jammerware pushed a commit to jammerware/MudBlazor that referenced this pull request Sep 20, 2022
* DateMask

* Fixed mask examples for small screens

* Add datemask example to docs

* MudPicker: support Masking

* Docs: DatePicker masking examples
3dots pushed a commit to 3dots/MudBlazor that referenced this pull request Mar 23, 2023
* DateMask

* Fixed mask examples for small screens

* Add datemask example to docs

* MudPicker: support Masking

* Docs: DatePicker masking examples
ferraridavide pushed a commit to ferraridavide/MudBlazor that referenced this pull request May 30, 2023
* DateMask

* Fixed mask examples for small screens

* Add datemask example to docs

* MudPicker: support Masking

* Docs: DatePicker masking examples
ilovepilav pushed a commit to ilovepilav/MudBlazor that referenced this pull request Nov 25, 2023
* DateMask

* Fixed mask examples for small screens

* Add datemask example to docs

* MudPicker: support Masking

* Docs: DatePicker masking examples
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Masking for MudDatePicker/MudTimePicker
2 participants