Skip to content

Add missing implementations of Immediate in BitPhoneInput (#12488)#12489

Open
msynk wants to merge 1 commit into
bitfoundation:developfrom
msynk:12488-blazorui-phoneinput-immediate
Open

Add missing implementations of Immediate in BitPhoneInput (#12488)#12489
msynk wants to merge 1 commit into
bitfoundation:developfrom
msynk:12488-blazorui-phoneinput-immediate

Conversation

@msynk

@msynk msynk commented Jun 19, 2026

Copy link
Copy Markdown
Member

closes #12488

Summary by CodeRabbit

Release Notes

New Features

  • PhoneInput component now supports input rate limiting with new DebounceTime and ThrottleTime parameters when immediate mode is enabled.
  • Enhanced PhoneInput demo with examples demonstrating immediate, debounced, and throttled input behaviors.

@coderabbitai

coderabbitai Bot commented Jun 19, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

BitPhoneInput gains DebounceTime and ThrottleTime parameters backed by a BitInputRateLimiter<ChangeEventArgs>. HandleOnNumberInput now routes events through the limiter when Immediate is active. The demo page adds a new "Immediate" example with three variants and renumbers the subsequent examples.

Changes

BitPhoneInput Immediate Rate Limiting

Layer / File(s) Summary
Rate limiter field, parameters, and input handler
src/BlazorUI/Bit.BlazorUI.Extras/Components/PhoneInput/BitPhoneInput.razor.cs
Adds a private _rateLimiter field of type BitInputRateLimiter<ChangeEventArgs>, two new [Parameter] integers DebounceTime and ThrottleTime, and rewires HandleOnNumberInput to pass events through _rateLimiter.Run(...) before invoking HandleOnNumberChange asynchronously.
Demo: Immediate examples, parameter docs, and renumbering
src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/PhoneInput/BitPhoneInputDemo.razor, src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/PhoneInput/BitPhoneInputDemo.razor.cs
Inserts example7 showing three Immediate variants (plain, DebounceTime="500", ThrottleTime="500"); adds DebounceTime and ThrottleTime entries to componentParameters; introduces immediateNumber, debouncedNumber, throttledNumber state fields; renumbers Events → example9, Style & Class → example10, RTL → example11.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 Hop, hop, throttle the beat,
Don't flood the input, keep it neat!
Debounce the keystrokes, one by one,
The phone field waits till typing's done.
A limiter leaps, swift and bright—
Rate-limited inputs, done just right! 🌟

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding missing Immediate feature implementations (Debounce and Throttle parameters) to BitPhoneInput.
Linked Issues check ✅ Passed The PR fully implements the missing Debounce and Throttle parameters for the Immediate feature in BitPhoneInput as required by issue #12488.
Out of Scope Changes check ✅ Passed All changes are directly related to implementing the missing Immediate feature parameters; demo updates support the new functionality appropriately.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
src/BlazorUI/Bit.BlazorUI.Extras/Components/PhoneInput/BitPhoneInput.razor.cs (2)

151-154: ⚡ Quick win

Document parameter precedence behavior.

Similar to DebounceTime, consider updating the description to mention that throttle is ignored when both DebounceTime and ThrottleTime are 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 win

Document parameter precedence behavior.

The parameter description doesn't mention that when both DebounceTime and ThrottleTime are greater than zero, debounce takes precedence and throttle is ignored (as per the BitInputRateLimiter.Run contract 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

📥 Commits

Reviewing files that changed from the base of the PR and between e943d52 and 6137b21.

📒 Files selected for processing (3)
  • src/BlazorUI/Bit.BlazorUI.Extras/Components/PhoneInput/BitPhoneInput.razor.cs
  • src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/PhoneInput/BitPhoneInputDemo.razor
  • src/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();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 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=f

Repository: bitfoundation/bitplatform

Length of output: 222


🏁 Script executed:

# Read the BitInputRateLimiter.cs file
cat -n src/BlazorUI/Bit.BlazorUI/Utils/BitInputRateLimiter.cs

Repository: bitfoundation/bitplatform

Length of output: 2668


🏁 Script executed:

# Find BitDebouncer and BitThrottler classes
rg -n 'class BitDebouncer|class BitThrottler' --type=cs -A 1

Repository: 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.cs

Repository: 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.cs

Repository: 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 -80

Repository: 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 20

Repository: 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.cs

Repository: 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.cs

Repository: 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incomplete implementation of the Immediate feature in the BitPhoneInput

1 participant