Repository navigation
Conversation
…hipFieldRequiredTest in Index.razor
…and add required chip validation tests
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #660 +/- ##
==========================================
+ Coverage 67.32% 67.78% +0.45%
==========================================
Files 117 118 +1
Lines 8550 8554 +4
Branches 1510 1514 +4
==========================================
+ Hits 5756 5798 +42
+ Misses 2253 2227 -26
+ Partials 541 529 -12 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A required
MudChipFieldwas validated against the text typed in its input instead of its chips, so it showed the required error even when it had chips, and it accepted typed text that wasn't a chip yet as a value.MudChipFieldhas two validators registered in the form: the chip field itself, and theMudTextFieldExtendedit renders inside (which is the one that displays the error). Both used the typed text to decide if there was a value. Changes:MudChipFieldoverridesHasValueto return true only when there is at least one chip, as suggested in the issue.ChipFieldTextField<T>, a small subclass ofMudTextFieldExtended<T>whoseHasValueasks the chip field if it has chips, so both validators agree. Without it, typing text cleared the error shown by the inner field, and validating the form again didn't bring it back because theErrorparameter passed down didn't change.ChipFieldTextFieldis public only because Razor can't render internal components, so I marked it[EditorBrowsable(Never)]. Happy to change the approach if you prefer another one.I also fixed the script reference in the UnitTests.Viewer
index.html: it pointed toMudExtensions.js, which doesn't exist (onlyMudExtensions.min.jsis shipped), somudBeforeInputwas undefined and the delimiter didn't work in the Viewer.Added
ChipFieldRequiredTestand unit tests for: valid with chips, invalid without chips, invalid with typed text but no chips, error kept after typing, valid after adding a chip, no error on blur with chips, and the required marker staying visible.Fixes #284
Before:
chip.error.mp4
After:
chip.fix.mp4