-
-
Notifications
You must be signed in to change notification settings - Fork 362
fix(Input): prevent focus exception #6920
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,5 +1,12 @@ | ||||||||||||||||||
| import EventHandler from "../../modules/event-handler.js" | ||||||||||||||||||
|
|
||||||||||||||||||
| export function focus(id) { | ||||||||||||||||||
| const el = document.getElementById(id) | ||||||||||||||||||
| if (el) { | ||||||||||||||||||
| el.focus(); | ||||||||||||||||||
|
||||||||||||||||||
| el.focus(); | |
| try { | |
| el.focus(); | |
| } catch (err) { | |
| console.error(`Failed to focus element with id '${id}':`, err); | |
| } | |
| } else { | |
| console.warn(`Element with id '${id}' not found. Cannot focus.`); |
ArgoZhang marked this conversation as resolved.
Show resolved
Hide resolved
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,11 +19,6 @@ public abstract class BootstrapInputBase<TValue> : ValidateBase<TValue> | |
| .AddClass(CssClass).AddClass(ValidCss) | ||
| .Build(); | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets Element reference instance | ||
| /// </summary> | ||
| protected ElementReference FocusElement { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets the placeholder attribute value | ||
| /// </summary> | ||
|
|
@@ -102,7 +97,7 @@ public abstract class BootstrapInputBase<TValue> : ValidateBase<TValue> | |
| /// Method to focus the element | ||
| /// </summary> | ||
| /// <returns></returns> | ||
| public async Task FocusAsync() => await FocusElement.FocusAsync(); | ||
| public async Task FocusAsync() => await InvokeVoidAsync("focus", GetInputId()); | ||
|
||
|
|
||
| /// <summary> | ||
| /// Method to select all text | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.