Conversation
Contributor
Reviewer's GuideAdds a clearable behavior and clear icon to DateTimePicker, including new parameters, styling, and tests, and hardens ValidateForm JS initialization against missing elements. Sequence diagram for DateTimePicker clear icon clearing valuesequenceDiagram
actor User
participant DateTimePicker_TValue_ as DateTimePicker
User->>DateTimePicker: OnClear
DateTimePicker->>DateTimePicker: OnClear
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- In
ClearClassString,ColorandIsValidcan both contribute atext-*class, which may result in conflicting color styles on the clear icon; consider prioritizing validation state or avoiding multiple text color classes at once. - The early return in
ValidateForm.initwhenelis null prevents null access but hides potential wiring issues; consider at least aconsole.debug/console.warnto make missing target elements easier to diagnose during integration.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `ClearClassString`, `Color` and `IsValid` can both contribute a `text-*` class, which may result in conflicting color styles on the clear icon; consider prioritizing validation state or avoiding multiple text color classes at once.
- The early return in `ValidateForm.init` when `el` is null prevents null access but hides potential wiring issues; consider at least a `console.debug`/`console.warn` to make missing target elements easier to diagnose during integration.
## Individual Comments
### Comment 1
<location path="src/BootstrapBlazor/Components/DateTimePicker/DateTimePicker.razor" line_range="26-28" />
<code_context>
{
<i class="@DateTimePickerIconClassString"></i>
}
+ @if (GetClearable())
+ {
+ <span class="@ClearClassString" @onclick:stopPropagation @onclick="OnClear"><i class="@ClearIcon"></i></span>
+ }
}
</code_context>
<issue_to_address>
**suggestion:** Improve accessibility of the clear icon trigger
The clear icon is currently a `<span>` with only a click handler, so it can’t be focused or activated via keyboard and has no role/label for assistive tech. Please make it keyboard- and screen-reader-friendly, e.g. by adding `tabindex="0"`, `role="button"`, handling Enter/Space in `@onkeydown` to call `OnClear`, and adding an `aria-label` if no visible text describes the action.
Suggested implementation:
```
@if (GetClearable())
{
<span class="@ClearClassString"
role="button"
tabindex="0"
aria-label="Clear value"
@onclick:stopPropagation
@onclick="OnClear"
@onkeydown="OnClearKeyDown">
<i class="@ClearIcon"></i>
</span>
}
```
To fully implement the keyboard support, add a key handler method (in the same `.razor` file inside an `@code` block, or in the corresponding `.razor.cs`/code-behind, depending on your existing pattern):
```csharp
private void OnClearKeyDown(Microsoft.AspNetCore.Components.Web.KeyboardEventArgs e)
{
if (e.Key == "Enter" || e.Key == " ")
{
OnClear();
}
}
```
If `Microsoft.AspNetCore.Components.Web` is not already imported in this file or the project-wide `_Imports.razor`, you may also need:
```razor
@using Microsoft.AspNetCore.Components.Web
```
If your component already uses localization or shared resource strings for ARIA text, replace the hard-coded `aria-label="Clear value"` with your localized string, e.g. `aria-label="@Localizer["Clear"]"` or a dedicated property.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8296 +/- ##
========================================
Coverage 99.99% 100.00%
========================================
Files 769 769
Lines 34478 34491 +13
========================================
+ Hits 34475 34491 +16
+ Misses 3 0 -3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Link issues
fixes #8293
Summary By Copilot
Regression?
Risk
Verification
Packaging changes reviewed?
☑️ Self Check before Merge
Summary by Sourcery
Add configurable clear icon support to DateTimePicker and tighten initialization in ValidateForm JS.
New Features:
Bug Fixes:
Enhancements: