-
-
Notifications
You must be signed in to change notification settings - Fork 375
feat(Table): use Enter/EscCallbck instead of keyup event #7672
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
f406072
ff74b67
10b6431
5f1d40f
3743221
eb714c8
55f076b
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 |
|---|---|---|
|
|
@@ -197,16 +197,17 @@ | |
| { | ||
| <Tooltip Placement="Placement.Top" Title="@SearchTooltip" Sanitize="false" IsHtml="true"> | ||
| <BootstrapInput class="table-toolbar-search" placeholder="@SearchPlaceholderText" | ||
| @onkeyup="OnSearchKeyUp" Value="@SearchText" | ||
| OnValueChanged="OnSearchTextValueChanged" | ||
| Value="@SearchText" SkipValidate="true" | ||
| OnEnterAsync="OnEnterAsync" OnEscAsync="OnEscAsync" | ||
| ShowLabel="false" UseInputEvent="AutoSearchOnInput"> | ||
| </BootstrapInput> | ||
| </Tooltip> | ||
| } | ||
| else | ||
| { | ||
| <BootstrapInput class="table-toolbar-search" placeholder="@SearchPlaceholderText" | ||
| Value="@SearchText" OnValueChanged="OnSearchTextValueChanged" | ||
| Value="@SearchText" SkipValidate="true" | ||
| OnEnterAsync="OnEnterAsync" OnEscAsync="OnEscAsync" | ||
|
Comment on lines
+209
to
+210
|
||
| ShowLabel="false" UseInputEvent="AutoSearchOnInput"> | ||
| </BootstrapInput> | ||
| } | ||
|
|
@@ -1049,18 +1050,18 @@ | |
| { | ||
| <Tooltip Placement="Placement.Top" Title="@SearchTooltip" Sanitize="false" IsHtml="true"> | ||
| <BootstrapInput class="table-toolbar-search" placeholder="@SearchPlaceholderText" | ||
| @onkeyup="OnSearchKeyUp" Value="@SearchText" | ||
| OnValueChanged="OnSearchTextValueChanged" | ||
| Value="@SearchText" | ||
| OnEnterAsync="OnEnterAsync" OnEscAsync="OnEscAsync" | ||
|
Comment on lines
+1053
to
+1054
|
||
| ShowLabel="false" SkipValidate="true" UseInputEvent="AutoSearchOnInput"> | ||
| </BootstrapInput> | ||
| </Tooltip> | ||
| } | ||
| else | ||
| { | ||
| <BootstrapInput class="table-toolbar-search" placeholder="@SearchPlaceholderText" | ||
| @onkeyup="OnSearchKeyUp" Value="@SearchText" | ||
| OnValueChanged="OnSearchTextValueChanged" | ||
| SkipValidate="true" UseInputEvent="AutoSearchOnInput"> | ||
| Value="@SearchText" | ||
| OnEnterAsync="OnEnterAsync" OnEscAsync="OnEscAsync" | ||
|
Comment on lines
+1062
to
+1063
|
||
| ShowLabel="false" SkipValidate="true" UseInputEvent="AutoSearchOnInput"> | ||
| </BootstrapInput> | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -408,10 +408,10 @@ public async Task OnSearchKeyUp_Ok() | |||||||||||||
| }); | ||||||||||||||
| }); | ||||||||||||||
| }); | ||||||||||||||
| var searchBox = cut.Find(".table-toolbar-search"); | ||||||||||||||
| await cut.InvokeAsync(() => searchBox.KeyUp(new KeyboardEventArgs() { Key = "Enter" })); | ||||||||||||||
| await cut.InvokeAsync(() => searchBox.KeyUp(new KeyboardEventArgs() { Key = "Escape" })); | ||||||||||||||
| await cut.InvokeAsync(() => searchBox.Change("0")); | ||||||||||||||
| var searchBox = cut.FindComponents<BootstrapInput<string?>>().FirstOrDefault(i => i.Markup.Contains("table-toolbar-search")); | ||||||||||||||
| Assert.NotNull(searchBox); | ||||||||||||||
|
||||||||||||||
| Assert.NotNull(searchBox); | |
| Assert.NotNull(searchBox); | |
| // Simulate user typing in the search box and verify that the table's SearchText is updated | |
| searchBox.Change("0"); | |
| var table = cut.FindComponent<Table<Foo>>(); | |
| Assert.Equal("0", table.Instance.SearchText); |
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.
The BootstrapInput component is missing two-way binding for the Value parameter. Currently only Value="@SearchText" is set, but there's no ValueChanged handler or @bind-Value directive. This means the SearchText property will not be updated as the user types in the search box, breaking the AutoSearchOnInput feature when UseInputEvent is set to AutoSearchOnInput (true).
The OnEnterAsync and OnEscAsync callbacks only update SearchText when Enter or Esc keys are pressed, but not during regular typing. To fix this, either: