-
-
Notifications
You must be signed in to change notification settings - Fork 362
feat(AutoComplete): use javascript update input value #6709
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
Conversation
Reviewer's GuideThis PR refactors the AutoComplete, AutoFill, and Search components to update their input elements’ values via JavaScript interop instead of Blazor two-way binding, introducing a new Sequence diagram for input value update via JavaScript in AutoComplete, AutoFill, and SearchsequenceDiagram
participant BlazorComponent as Blazor Component
participant JSInterop as JS Interop
participant JS as JavaScript
BlazorComponent->>JSInterop: InvokeVoidAsync("setValue", Id, value)
JSInterop->>JS: setValue(id, value)
JS->>JS: input.value = value
Class diagram for updated AutoComplete, AutoFill, and Search componentsclassDiagram
class AutoComplete {
+Task InvokeInitAsync()
+Task OnClickItem(string val)
}
class AutoFill {
+Task InvokeInitAsync()
+Task OnClearValue()
+Task OnClickItem(TValue val)
}
class Search {
+Task InvokeInitAsync()
+Task OnClearClick()
+Task OnClickItem(TValue val)
}
AutoComplete --|> ComponentBase
AutoFill --|> ComponentBase
Search --|> ComponentBase
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
Pull Request Overview
Updates AutoComplete components to use JavaScript for input value management instead of Blazor data binding, addressing issue #6708.
- Removes
@binddirectives from input elements in AutoComplete, AutoFill, and Search components - Adds JavaScript
setValuefunction and corresponding C# method calls for programmatic value updates - Updates unit tests to reflect that input values are no longer bound through HTML attributes
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| test/UnitTest/Components/AutoFillTest.cs | Updates test assertion to expect null value attribute |
| src/BootstrapBlazor/Components/Search/Search.razor.cs | Adds JavaScript setValue calls and InvokeInitAsync override |
| src/BootstrapBlazor/Components/Search/Search.razor | Removes @Bind directive from input element |
| src/BootstrapBlazor/Components/AutoFill/AutoFill.razor.cs | Adds JavaScript setValue calls and InvokeInitAsync override |
| src/BootstrapBlazor/Components/AutoFill/AutoFill.razor | Removes @Bind directive from input element |
| src/BootstrapBlazor/Components/AutoComplete/PopoverCompleteBase.cs | Removes base InvokeInitAsync method |
| src/BootstrapBlazor/Components/AutoComplete/AutoComplete.razor.js | Implements setValue JavaScript function |
| src/BootstrapBlazor/Components/AutoComplete/AutoComplete.razor.cs | Adds JavaScript setValue calls and InvokeInitAsync override |
| src/BootstrapBlazor/Components/AutoComplete/AutoComplete.razor | Removes @Bind directive from input element |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
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.
Hey there - I've reviewed your changes - here's some feedback:
- Since you removed the Razor @Bind on the inputs, double-check that your JS init logic still wires up input events to update the .NET state so user typing flows back into CurrentValue.
- There’s a lot of repeated InvokeVoidAsync("setValue", …) calls across components – consider extracting a shared helper or base method to avoid duplication.
- Confirm that dropping the InvokeInitAsync override in PopoverCompleteBase doesn’t regress popover autocomplete initialization.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Since you removed the Razor @bind on the inputs, double-check that your JS init logic still wires up input events to update the .NET state so user typing flows back into CurrentValue.
- There’s a lot of repeated InvokeVoidAsync("setValue", …) calls across components – consider extracting a shared helper or base method to avoid duplication.
- Confirm that dropping the InvokeInitAsync override in PopoverCompleteBase doesn’t regress popover autocomplete initialization.
## Individual Comments
### Comment 1
<location> `src/BootstrapBlazor/Components/AutoComplete/AutoComplete.razor.js:178` </location>
<code_context>
}
}
+export function setValue(id, value) {
+ const ac = Data.get(id)
+ const { input } = ac;
+ if (input) {
+ input.value = value;
+ }
+}
+
</code_context>
<issue_to_address>
Consider handling cases where Data.get(id) or ac.input is undefined.
If either is undefined, consider logging a warning or handling the case explicitly to improve debuggability.
</issue_to_address>
<suggested_fix>
<<<<<<< SEARCH
export function setValue(id, value) {
const ac = Data.get(id)
const { input } = ac;
if (input) {
input.value = value;
}
}
=======
export function setValue(id, value) {
const ac = Data.get(id);
if (!ac) {
console.warn(`AutoComplete: No entry found for id '${id}' in Data.`);
return;
}
const { input } = ac;
if (!input) {
console.warn(`AutoComplete: No input found for id '${id}'.`);
return;
}
input.value = value;
}
>>>>>>> REPLACE
</suggested_fix>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6709 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 739 739
Lines 31706 31713 +7
Branches 4462 4462
=========================================
+ Hits 31706 31713 +7
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Link issues
fixes #6708
Summary By Copilot
Regression?
Risk
Verification
Packaging changes reviewed?
☑️ Self Check before Merge
Summary by Sourcery
Use JavaScript interop to update input values in AutoComplete, AutoFill, and Search components instead of Blazor bindings, and adjust initialization and tests accordingly.
Bug Fixes:
Enhancements:
Tests:
Chores: