Skip to content

OTP Input#1238

Merged
gvreddy04 merged 6 commits intomainfrom
features/otp-input
Jan 31, 2026
Merged

OTP Input#1238
gvreddy04 merged 6 commits intomainfrom
features/otp-input

Conversation

@gvreddy04
Copy link
Contributor

No description provided.

- Refactored OTPInput component to use more specific JS interop functions: replaced FocusElement with FocusInputElement and added SetInputElementValue for programmatically clearing input fields.
- Added debug Console.WriteLine statements to OTPInput for easier tracing.
- Updated OTP input margin class from MarginEnd1 to MarginEnd2 for improved spacing.
- Added a new CharExtensions static class with an IsAlphanumeric extension method for char.
Refactored the OnInput method to sanitize input by allowing only digits, handle pasted or fast-typed multiple digits by using the last digit, and clear invalid input both in state and DOM. Updated the input field if the raw value doesn't match the sanitized digit and streamlined focus movement logic. Removed unnecessary else branches and debug statements for cleaner code.
@gvreddy04 gvreddy04 added this to the 4.0.0 milestone Jan 7, 2026
@gvreddy04 gvreddy04 self-assigned this Jan 7, 2026
- Allow multi-digit paste by setting maxlength=6 on input fields.
- Distribute pasted digits across OTP fields and update focus accordingly.
- Add SafeInvokeVoidAsync to safely wrap JS interop calls.
- Replace direct JSRuntime.InvokeVoidAsync calls with SafeInvokeVoidAsync to handle component disposal and JS runtime disconnects gracefully.
- Remove old logic that only used the last digit on multi-digit input.
- Improves robustness and user experience during input and navigation.
Introduce SafeInvokeVoidAsync in BlazorBootstrapComponentBase to safely handle JSRuntime calls, preventing exceptions on disposal or JS disconnect. Refactor all components to use this method instead of direct JSRuntime.InvokeVoidAsync calls. Add isJsRuntimeAvailable flag to skip future JS calls after disconnect. Enhance Tabs disposal logic and remove redundant SafeInvokeVoidAsync from OTPInput. Add global using for Microsoft.JSInterop. Update PDF JS initialization to check for canvas existence before creating Pdf instance.
Introduce JsInteropBase to centralize JS module management and safe invocation for Blazor components. Refactor PdfViewerJsInterop, SortableListJsInterop, and ThemeSwitcherJsInterop to inherit from this base class, removing redundant DisposeAsync logic. Replace direct JSRuntime.InvokeVoidAsync calls with SafeInvokeVoidAsync across components (charts, Demo, Snippet, Toasts) to handle disconnects and cancellations gracefully. Remove unused JS property from Demo. Improves robustness and maintainability of JS interop throughout the codebase.
@gvreddy04 gvreddy04 merged commit d4321fc into main Jan 31, 2026
1 of 3 checks passed
@gvreddy04 gvreddy04 deleted the features/otp-input branch January 31, 2026 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant