Add missing implementations of Immediate in BitPhoneInput (#12488)#12489
Add missing implementations of Immediate in BitPhoneInput (#12488)#12489msynk wants to merge 1 commit into
Conversation
Walkthrough
ChangesBitPhoneInput Immediate Rate Limiting
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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.
Actionable comments posted: 1
🧹 Nitpick comments (2)
src/BlazorUI/Bit.BlazorUI.Extras/Components/PhoneInput/BitPhoneInput.razor.cs (2)
151-154: ⚡ Quick winDocument parameter precedence behavior.
Similar to
DebounceTime, consider updating the description to mention that throttle is ignored when bothDebounceTimeandThrottleTimeare set (debounce takes precedence).📝 Suggested description improvement
/// <summary> -/// The throttle time in milliseconds for the number input (applied when Immediate is enabled). +/// The throttle time in milliseconds for the number input (applied when Immediate is enabled). Ignored when DebounceTime is also set. /// </summary>🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/BlazorUI/Bit.BlazorUI.Extras/Components/PhoneInput/BitPhoneInput.razor.cs` around lines 151 - 154, The documentation for the ThrottleTime parameter lacks information about its interaction with DebounceTime. Update the XML documentation comment for the ThrottleTime parameter to explicitly mention that throttle is ignored when both DebounceTime and ThrottleTime are set, with debounce taking precedence. This ensures users understand the parameter behavior and precedence rules, similar to how DebounceTime is already documented.
69-72: ⚡ Quick winDocument parameter precedence behavior.
The parameter description doesn't mention that when both
DebounceTimeandThrottleTimeare greater than zero, debounce takes precedence and throttle is ignored (as per theBitInputRateLimiter.Runcontract in context snippet 1). Consider updating the description to note this precedence to prevent confusion when users set both parameters.📝 Suggested description improvement
/// <summary> -/// The debounce time in milliseconds for the number input (applied when Immediate is enabled). +/// The debounce time in milliseconds for the number input (applied when Immediate is enabled). When both DebounceTime and ThrottleTime are set, debounce takes precedence. /// </summary>🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/BlazorUI/Bit.BlazorUI.Extras/Components/PhoneInput/BitPhoneInput.razor.cs` around lines 69 - 72, The XML documentation summary for the DebounceTime parameter in the BitPhoneInput class does not document the precedence behavior when both DebounceTime and ThrottleTime are set. Update the summary comment for the DebounceTime parameter to clarify that when both values are greater than zero, debounce takes precedence and throttle is ignored, following the contract defined in BitInputRateLimiter.Run.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@src/BlazorUI/Bit.BlazorUI.Extras/Components/PhoneInput/BitPhoneInput.razor.cs`:
- Line 11: The BitPhoneInput component has a _rateLimiter field of type
BitInputRateLimiter<ChangeEventArgs> that holds internal disposable resources
(BitDebouncer and BitThrottler objects with CancellationTokenSource instances).
You need to ensure these resources are properly cleaned up by calling
_rateLimiter.Reset() in the DisposeAsync method of BitPhoneInput. Add this
method call to the DisposeAsync method following the same pattern used in other
components like BitDropdown and BitTextInputBase, which already implement this
cleanup to prevent resource leaks.
---
Nitpick comments:
In
`@src/BlazorUI/Bit.BlazorUI.Extras/Components/PhoneInput/BitPhoneInput.razor.cs`:
- Around line 151-154: The documentation for the ThrottleTime parameter lacks
information about its interaction with DebounceTime. Update the XML
documentation comment for the ThrottleTime parameter to explicitly mention that
throttle is ignored when both DebounceTime and ThrottleTime are set, with
debounce taking precedence. This ensures users understand the parameter behavior
and precedence rules, similar to how DebounceTime is already documented.
- Around line 69-72: The XML documentation summary for the DebounceTime
parameter in the BitPhoneInput class does not document the precedence behavior
when both DebounceTime and ThrottleTime are set. Update the summary comment for
the DebounceTime parameter to clarify that when both values are greater than
zero, debounce takes precedence and throttle is ignored, following the contract
defined in BitInputRateLimiter.Run.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 9d77b7bc-1792-40c2-a6ef-37d0edb337d4
📒 Files selected for processing (3)
src/BlazorUI/Bit.BlazorUI.Extras/Components/PhoneInput/BitPhoneInput.razor.cssrc/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/PhoneInput/BitPhoneInputDemo.razorsrc/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/PhoneInput/BitPhoneInputDemo.razor.cs
| /// </summary> | ||
| public partial class BitPhoneInput : BitInputBase<string?> | ||
| { | ||
| private readonly BitInputRateLimiter<ChangeEventArgs> _rateLimiter = new(); |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Check if BitInputRateLimiter implements IDisposable or IAsyncDisposable
ast-grep --pattern $'class BitInputRateLimiter$$$: $$$IDisposable$$$'
ast-grep --pattern $'class BitInputRateLimiter$$$: $$$IAsyncDisposable$$$'
# Also check for any Dispose methods
rg -nP --type=cs -A5 'class\s+BitInputRateLimiter' | rg -P '(Dispose|IDisposable|IAsyncDisposable)'Repository: bitfoundation/bitplatform
Length of output: 51
🏁 Script executed:
# Find BitInputRateLimiter class definition
rg -n 'class BitInputRateLimiter' --type=cs
# Also search for the file that contains this class
fd -i 'bitinputratelimiter' --type=fRepository: bitfoundation/bitplatform
Length of output: 222
🏁 Script executed:
# Read the BitInputRateLimiter.cs file
cat -n src/BlazorUI/Bit.BlazorUI/Utils/BitInputRateLimiter.csRepository: bitfoundation/bitplatform
Length of output: 2668
🏁 Script executed:
# Find BitDebouncer and BitThrottler classes
rg -n 'class BitDebouncer|class BitThrottler' --type=cs -A 1Repository: bitfoundation/bitplatform
Length of output: 328
🏁 Script executed:
# Read BitDebouncer.cs
echo "=== BitDebouncer.cs ===" && cat -n src/BlazorUI/Bit.BlazorUI/Utils/BitDebouncer.cs
# Read BitThrottler.cs
echo "=== BitThrottler.cs ===" && cat -n src/BlazorUI/Bit.BlazorUI/Utils/BitThrottler.csRepository: bitfoundation/bitplatform
Length of output: 2410
🏁 Script executed:
# Check BitPhoneInput DisposeAsync method around lines 515-533
sed -n '515,533p' src/BlazorUI/Bit.BlazorUI.Extras/Components/PhoneInput/BitPhoneInput.razor.csRepository: bitfoundation/bitplatform
Length of output: 661
🏁 Script executed:
# Search for BitInputRateLimiter usage in component files
rg -n 'BitInputRateLimiter' --type=cs -B 2 -A 2 | head -80Repository: bitfoundation/bitplatform
Length of output: 2249
🏁 Script executed:
# Check BitDropdown DisposeAsync method
rg -n 'DisposeAsync' src/BlazorUI/Bit.BlazorUI/Components/Inputs/Dropdown/BitDropdown.razor.cs -A 20
# Check BitTextInputBase DisposeAsync method
rg -n 'DisposeAsync' src/BlazorUI/Bit.BlazorUI/Components/Inputs/BitTextInputBase.cs -A 20Repository: bitfoundation/bitplatform
Length of output: 735
🏁 Script executed:
# Get the line numbers where DisposeAsync appears in BitDropdown
grep -n 'DisposeAsync' src/BlazorUI/Bit.BlazorUI/Components/Inputs/Dropdown/BitDropdown.razor.cs
# Then check if _rateLimiter.Reset() is called
rg -n '_rateLimiter\.Reset' src/BlazorUI/Bit.BlazorUI/Components/Inputs/Dropdown/BitDropdown.razor.csRepository: bitfoundation/bitplatform
Length of output: 331
🏁 Script executed:
# Check if BitDropdown's DisposeAsync calls _rateLimiter.Reset()
sed -n '1767,1790p' src/BlazorUI/Bit.BlazorUI/Components/Inputs/Dropdown/BitDropdown.razor.csRepository: bitfoundation/bitplatform
Length of output: 625
Call _rateLimiter.Reset() in the DisposeAsync method.
The _rateLimiter field holds a BitInputRateLimiter<ChangeEventArgs> instance that manages internal BitDebouncer and BitThrottler objects. Both of these classes hold CancellationTokenSource instances that must be disposed. The Reset() method properly disposes these resources, but BitPhoneInput.DisposeAsync does not call it. Other components using BitInputRateLimiter (such as BitDropdown and BitTextInputBase) correctly call _rateLimiter.Reset() during disposal. Add this call to prevent resource leaks.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In
`@src/BlazorUI/Bit.BlazorUI.Extras/Components/PhoneInput/BitPhoneInput.razor.cs`
at line 11, The BitPhoneInput component has a _rateLimiter field of type
BitInputRateLimiter<ChangeEventArgs> that holds internal disposable resources
(BitDebouncer and BitThrottler objects with CancellationTokenSource instances).
You need to ensure these resources are properly cleaned up by calling
_rateLimiter.Reset() in the DisposeAsync method of BitPhoneInput. Add this
method call to the DisposeAsync method following the same pattern used in other
components like BitDropdown and BitTextInputBase, which already implement this
cleanup to prevent resource leaks.
closes #12488
Summary by CodeRabbit
Release Notes
New Features
DebounceTimeandThrottleTimeparameters when immediate mode is enabled.