-
-
Notifications
You must be signed in to change notification settings - Fork 260
Add Clear button feature to BitTextField component (#11847) #11936
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
Add Clear button feature to BitTextField component (#11847) #11936
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughThis PR adds a clear button feature to BitTextField component. The implementation introduces a ShowClearButton parameter to conditionally display a clear button, an OnClear callback for handling clear actions, associated styling, and style customization properties. Demo examples have been reordered to showcase the new feature alongside existing functionality. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
Pre-merge checks and finishing touches❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
🧹 Nitpick comments (1)
src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Inputs/TextField/BitTextFieldDemo.razor (1)
145-151: Consider adding demos for OnClear callback and ClearIconName parameter.The current demo shows basic ShowClearButton usage, which is good. However, issue #11847 mentioned two additional optional parameters that aren't demonstrated:
- OnClear callback: Should show how to capture the current value and return a bool to block the clear action.
- ClearIconName parameter: Should show how to customize the clear icon.
Adding these demos would help users understand the full feature set.
💡 Example demo additions
<DemoExample Title="ShowClearButton with OnClear callback" RazorCode="@example9bRazorCode" CsharpCode="@example9bCsharpCode" Id="example9b"> <div>Demonstrates the OnClear callback that can prevent clearing based on custom logic.</div> <br /> <div class="example-box"> <BitTextField Label="Email (requires confirmation)" @bind-Value="emailValue" ShowClearButton OnClear="HandleOnClear" /> <div>Value: [@emailValue]</div> <div>Clear attempts: @clearAttempts</div> </div> </DemoExample> <DemoExample Title="ShowClearButton with custom icon" RazorCode="@example9cRazorCode" Id="example9c"> <div>Demonstrates using a custom icon for the clear button.</div> <br /> <div class="example-box"> <BitTextField Label="Search" DefaultValue="query" ShowClearButton ClearIconName="@BitIconName.ChromeClose" /> </div> </DemoExample>
📜 Review details
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting
📒 Files selected for processing (6)
src/BlazorUI/Bit.BlazorUI/Components/Inputs/TextField/BitTextField.razorsrc/BlazorUI/Bit.BlazorUI/Components/Inputs/TextField/BitTextField.razor.cssrc/BlazorUI/Bit.BlazorUI/Components/Inputs/TextField/BitTextField.scsssrc/BlazorUI/Bit.BlazorUI/Components/Inputs/TextField/BitTextFieldClassStyles.cssrc/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Inputs/TextField/BitTextFieldDemo.razorsrc/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Inputs/TextField/BitTextFieldDemo.razor.cs
🧰 Additional context used
🧬 Code graph analysis (1)
src/BlazorUI/Bit.BlazorUI/Components/Inputs/TextField/BitTextField.razor.cs (1)
src/BlazorUI/Bit.BlazorUI/Components/Inputs/SearchBox/BitSearchBox.razor.cs (8)
Task(207-211)Task(287-301)Task(334-342)Task(344-355)Task(357-364)Task(366-375)Task(377-435)Task(437-450)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build Bit.BlazorUI
🔇 Additional comments (9)
src/BlazorUI/Bit.BlazorUI/Components/Inputs/TextField/BitTextFieldClassStyles.cs (1)
60-68: LGTM! Well-structured styling properties.The new
ClearButtonandClearButtonIconproperties are properly documented and logically positioned alongside the reveal password styling properties.src/BlazorUI/Bit.BlazorUI/Components/Inputs/TextField/BitTextField.razor.cs (1)
195-198: LGTM! Parameter is well-documented.The
ShowClearButtonparameter is properly implemented with clear documentation.src/BlazorUI/Bit.BlazorUI/Components/Inputs/TextField/BitTextField.scss (2)
35-42: LGTM! Consistent disabled state styling.The disabled styling for the clear button properly handles cursor, pointer-events, and visual styling, consistent with other disabled elements in the component.
175-212: LGTM! Comprehensive button styling.The clear button styling is well-structured with:
- Proper button reset and positioning
- Icon sizing and alignment
- Interactive hover states
- Consistent design language with the reveal password button
src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Inputs/TextField/BitTextFieldDemo.razor.cs (1)
136-140: LGTM! Comprehensive parameter documentation.The documentation for
OnClear,ShowClearButton, and the new class styles properties is clear, well-structured, and consistent with existing documentation patterns.Also applies to: 233-238, 374-386
src/BlazorUI/Bit.BlazorUI/Components/Inputs/TextField/BitTextField.razor (3)
118-133: Good addition oftype="button"to prevent form submission.Adding
type="button"to the reveal password button (line 121) is a good defensive practice that prevents accidental form submission. This aligns with the clear button implementation and improves overall UX consistency.
128-130: Excellent accessibility improvements witharia-hidden="true"on decorative icons.Adding
aria-hidden="true"to the reveal password icon (line 128) and the general icon (line 137) is the correct approach for decorative icons. This ensures screen readers don't announce redundant information since the parent elements already provide accessible context througharia-labelor other attributes.Also applies to: 137-139
104-104:HandleOnClearButtonClickis properly implemented.The method exists in the code-behind file at line 438 and correctly handles all required operations: clears the text via
SetCurrentValueAsStringAsync(string.Empty, true), focuses the input viaInputElement.FocusAsync(), invokes theOnClearcallback, and guards against disabled/read-only states with an early return check.src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Inputs/TextField/BitTextFieldDemo.razor (1)
153-345: Excellent job maintaining consistency in example renumbering.All subsequent examples have been correctly renumbered from example9-16 to example10-17 to accommodate the new ShowClearButton demo. The IDs, RazorCode references, and CsharpCode references are all consistent and properly updated.
closes #11847
Summary by CodeRabbit
ShowClearButtonparameter and handle clear events with theOnClearcallback.✏️ Tip: You can customize this high-level summary in your review settings.