-
-
Notifications
You must be signed in to change notification settings - Fork 384
fix(AutoComplete): studder on long running OnValueChanged function call #5819
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
Merged
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
8a30015
fix studder
celadaris 8afcaf2
update
celadaris 7de19f6
Update AutoComplete.razor.js
celadaris 01178b7
Update AutoComplete.razor.cs
celadaris abb3027
rollback
celadaris fd89544
Update AutoComplete.razor.cs
celadaris a674583
Merge branch 'main' into studder
celadaris 4635a24
Update AutoComplete.razor.cs
celadaris 9550496
Merge branch 'main' into studder
ArgoZhang 3db7c8a
refactor: 精简代码
ArgoZhang b6b174c
Revert "doc: 更新测试用例"
ArgoZhang ab85582
doc: 更新示例
ArgoZhang 565024c
refactor: 精简 js 逻辑
ArgoZhang 30f1f16
refactor: 使用 bind 防止卡顿
ArgoZhang bb57b03
refactor: 重构 show/closee 方法
ArgoZhang 280414e
revert: 撤销 EnterCallback 参数
ArgoZhang c15ac74
doc: 更新测试用例
ArgoZhang 1f318a3
refactor: 移除不使用的代码
ArgoZhang 9cbfea1
test: 更新单元测试
ArgoZhang 9f92a43
refactor: 移除 TriggerChange 方法
ArgoZhang 3db66b6
Merge branch 'fix-auto' into studder
ArgoZhang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
69 changes: 47 additions & 22 deletions
69
src/BootstrapBlazor/Components/AutoComplete/AutoComplete.razor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,47 +1,72 @@ | ||
| @namespace BootstrapBlazor.Components | ||
| @* --- File: AutoComplete.razor --- *@ | ||
| @namespace BootstrapBlazor.Components | ||
| @inherits PopoverCompleteBase<string> | ||
|
|
||
| @* Show label if configured *@ | ||
| @if (IsShowLabel) | ||
| { | ||
| <BootstrapLabel required="@Required" for="@InputId" ShowLabelTooltip="ShowLabelTooltip" Value="@DisplayText"/> | ||
| <BootstrapLabel required="@Required" for="@InputId" ShowLabelTooltip="ShowLabelTooltip" Value="@DisplayText" /> | ||
| } | ||
|
|
||
| @* Main container div *@ | ||
| <div class="auto-complete" id="@Id"> | ||
| <input @attributes="AdditionalAttributes" id="@InputId" class="@ClassName" autocomplete="off" type="text" | ||
| data-bs-toggle="@ToggleString" data-bs-placement="@PlacementString" | ||
| data-bs-offset="@OffsetString" data-bs-custom-class="@CustomClassString" | ||
| data-bb-auto-dropdown-focus="@ShowDropdownListOnFocusString" data-bb-debounce="@DurationString" | ||
| data-bb-skip-esc="@SkipEscString" data-bb-skip-enter="@SkipEnterString" data-bb-blur="@TriggerBlurString" | ||
| data-bb-scroll-behavior="@ScrollIntoViewBehaviorString" data-bb-trigger-delete="true" | ||
| value="@CurrentValueAsString" | ||
| placeholder="@PlaceHolder" disabled="@Disabled" @ref="FocusElement"/> | ||
| @* Input element - Value is now controlled primarily by the browser & JS setValue *@ | ||
| <input @attributes="AdditionalAttributes" | ||
| id="@InputId" | ||
| class="@ClassName" | ||
| autocomplete="off" | ||
| type="text" | ||
| data-bs-toggle="@ToggleString" | ||
| data-bs-placement="@PlacementString" | ||
| data-bs-offset="@OffsetString" | ||
| data-bs-custom-class="@CustomClassString" | ||
| data-bb-auto-dropdown-focus="@ShowDropdownListOnFocusString" | ||
| data-bb-debounce="@DurationString" | ||
| data-bb-skip-esc="@SkipEscString" | ||
| data-bb-skip-enter="@SkipEnterString" | ||
| data-bb-blur="@TriggerBlurString" | ||
| data-bb-scroll-behavior="@ScrollIntoViewBehaviorString" | ||
| data-bb-trigger-delete="true" | ||
| placeholder="@PlaceHolder" | ||
| disabled="@Disabled" | ||
| @ref="FocusElement" /> | ||
|
|
||
| @* Icon shown by default *@ | ||
| <span class="form-select-append"><i class="@Icon"></i></span> | ||
| @* Loading icon shown during filtering *@ | ||
| <span class="form-select-append ac-loading"><i class="@LoadingIcon"></i></span> | ||
|
|
||
| @* Render the dropdown menu using RenderFragment *@ | ||
| <RenderTemplate @ref="_dropdown"> | ||
| @RenderDropdown | ||
| </RenderTemplate> | ||
| </div> | ||
|
|
||
| @code { | ||
| // RenderFragment for the dropdown menu content | ||
| RenderFragment RenderDropdown => | ||
| @<div class="dropdown-menu"> | ||
| <div class="dropdown-menu-body"> | ||
| @* Iterate through filtered items (Rows) *@ | ||
| @foreach (var item in Rows) | ||
| { | ||
| <div @key="item" class="dropdown-item" @onclick="() => OnClickItem(item)"> | ||
| @* Use ItemTemplate if provided, otherwise display item directly *@ | ||
| @if (ItemTemplate == null) | ||
| { | ||
| <div @key="item" class="dropdown-item" @onclick="() => OnClickItem(item)"> | ||
| @if (ItemTemplate == null) | ||
| { | ||
| <div>@item</div> | ||
| } | ||
| else | ||
| { | ||
| @ItemTemplate(item) | ||
| } | ||
| </div> | ||
| <div>@item</div> | ||
| } | ||
| @if (ShowNoDataTip && Rows.Count == 0) | ||
| else | ||
| { | ||
| <div class="dropdown-item">@NoDataTip</div> | ||
| @ItemTemplate(item) | ||
| } | ||
| </div> | ||
| } | ||
| @* Show "No data" tip if configured and no items match *@ | ||
| @if (ShowNoDataTip && !Rows.Any()) // Use !Rows.Any() for clarity | ||
| { | ||
| <div class="dropdown-item disabled">@NoDataTip</div> @* Add 'disabled' class? *@ | ||
| } | ||
| </div> | ||
| </div>; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.