-
Notifications
You must be signed in to change notification settings - Fork 377
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Migrate Demo Search to use FluentAutocomplete (#1599)
* refactor: Migrate Demo Search to use FluentAutocomplete * refactor: Code review comments * fix: Revert breaking change for now * test: ValueText & ValueTextChanged * fix: regenerate * test: Overlay on clear behaviours * fix: random IDs being generated in test * fix: valuetext as well --------- Co-authored-by: Vincent Baaij <[email protected]>
- Loading branch information
Showing
10 changed files
with
233 additions
and
75 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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,24 +1,18 @@ | ||
<FluentSearch @bind-Value="@_searchValue" | ||
Immediate | ||
@bind-Value:after="HandleSearchInput" | ||
Id="demo-search" | ||
Placeholder="Search everything..."/> | ||
|
||
@if (_searchResults is not null) | ||
{ | ||
<FluentMenu Anchor="demo-search" | ||
HorizontalPosition="HorizontalPosition.Right" | ||
@bind-Open="_visible"> | ||
@foreach (var searchResult in _searchResults) | ||
{ | ||
var item = NavProvider.FlattenedMenuItems.First(x => x.Title == searchResult); | ||
|
||
<FluentMenuItem OnClick="@(() => HandleSearchClicked(item))"> | ||
<span slot="start"> | ||
<FluentIcon Value="@(item.Icon)" Class="search-result-icon" Color="Color.Neutral" Slot="start"/> | ||
</span> | ||
@item.Title | ||
</FluentMenuItem> | ||
} | ||
</FluentMenu> | ||
} | ||
<FluentAutocomplete TOption="NavItem" | ||
Width="200px" | ||
AutoComplete="off" | ||
Placeholder="Search everything..." | ||
MaximumSelectedOptions="1" | ||
OptionText="@(item => item.Title)" | ||
@bind-ValueText="@_searchTerm" | ||
@bind-SelectedOptions="_selectedOptions" | ||
@bind-SelectedOptions:after="HandleSearchClicked" | ||
OnOptionsSearch="@HandleSearchInput" | ||
ShowOverlayOnEmptyResults="false"> | ||
<OptionTemplate> | ||
<span slot="start"> | ||
<FluentIcon Value="@(context.Icon)" Class="search-result-icon" Color="Color.Neutral" Slot="start"/> | ||
</span> | ||
@context.Title | ||
</OptionTemplate> | ||
</FluentAutocomplete> |
This file contains 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
This file contains 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
This file contains 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
9 changes: 9 additions & 0 deletions
9
...mpleteTests.FluentAutocomplete_OnClearWithOverlayHiddenOnEmpty_HasNoOverlay.verified.html
This file contains 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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
|
||
<div class=" fluent-autocomplete-multiselect" style="width: 100%;" b-hg72r5b4ox=""> | ||
<fluent-text-field style="width: 100%; min-width: 100%;" placeholder="" id="xxx" value="" current-value="" appearance="outline" blazor:onchange="1" role="combobox" aria-expanded="true" aria-controls="myComponent-popup" aria-label="No items found" blazor:onclick="2" blazor:oninput="3" blazor:onfocusout="4" blazor:elementreference=""> | ||
<svg slot="end" style="width: 16px; fill: var(--accent-fill-rest); cursor: pointer;" focusable="false" viewBox="0 0 16 16" aria-hidden="true" blazor:onclick="6"> | ||
<title>Search</title> | ||
<path d="M9.1 10.17a4.5 4.5 0 1 1 1.06-1.06l3.62 3.61a.75.75 0 1 1-1.06 1.06l-3.61-3.61Zm.4-3.67a3 3 0 1 0-6 0 3 3 0 0 0 6 0Z"></path> | ||
</svg> | ||
</fluent-text-field> | ||
</div> |
17 changes: 17 additions & 0 deletions
17
tests/Core/List/FluentAutocompleteTests.FluentAutocomplete_OnClear_ShowOverlay.verified.html
This file contains 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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
|
||
<div class=" fluent-autocomplete-multiselect" style="width: 100%;" b-hg72r5b4ox=""> | ||
<fluent-text-field style="width: 100%; min-width: 100%;" placeholder="" id="xxx" value="" current-value="" appearance="outline" blazor:onchange="1" role="combobox" aria-expanded="true" aria-controls="myComponent-popup" aria-label="No items found" blazor:onclick="2" blazor:oninput="3" blazor:onfocusout="4" blazor:elementreference=""> | ||
<svg slot="end" style="width: 16px; fill: var(--accent-fill-rest); cursor: pointer;" focusable="false" viewBox="0 0 16 16" aria-hidden="true" blazor:onclick="6"> | ||
<title>Search</title> | ||
<path d="M9.1 10.17a4.5 4.5 0 1 1 1.06-1.06l3.62 3.61a.75.75 0 1 1-1.06 1.06l-3.61-3.61Zm.4-3.67a3 3 0 1 0-6 0 3 3 0 0 0 6 0Z"></path> | ||
</svg> | ||
</fluent-text-field> | ||
<div class="fluent-overlay" style="cursor: auto; position: fixed; z-index: 9900;" blazor:onclick="7" blazor:oncontextmenu="8" blazor:oncontextmenu:preventdefault="" b-xkrr7evqik=""> | ||
<div style="display: flex; align-items:center; justify-content: center; width: 100%; height: 100%" b-xkrr7evqik=""></div> | ||
</div> | ||
<fluent-anchored-region anchor="xxx" horizontal-positioning-mode="dynamic" horizontal-default-position="right" horizontal-inset="" horizontal-threshold="0" horizontal-scaling="content" vertical-positioning-mode="dynamic" vertical-default-position="unset" vertical-threshold="0" vertical-scaling="content" auto-update-mode="auto" style="z-index: 9999;" b-2ov9fhztky="" blazor:elementreference="xxx"> | ||
<div style="z-index: 9999; background-color: var(--neutral-layer-floating); box-shadow: var(--elevation-shadow-flyout); margin-top: 10px; border-radius: calc(var(--control-corner-radius) * 2px); background-color: var(--neutral-layer-floating);" b-2ov9fhztky=""> | ||
<div id="xxx" role="listbox" style="width: 100%;" tabindex="0" b-hg72r5b4ox=""></div> | ||
</div> | ||
</fluent-anchored-region> | ||
</div> |
9 changes: 9 additions & 0 deletions
9
tests/Core/List/FluentAutocompleteTests.FluentAutocomplete_ValueText.verified.html
This file contains 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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
|
||
<div class=" fluent-autocomplete-multiselect" style="width: 100%;" b-hg72r5b4ox=""> | ||
<fluent-text-field style="width: 100%; min-width: 100%;" placeholder="" id="xxx" value="Preselected value" current-value="Preselected value" appearance="outline" blazor:onchange="1" role="combobox" aria-expanded="false" aria-controls="" blazor:onclick="2" blazor:oninput="3" blazor:onfocusout="4" blazor:elementreference="xxx"> | ||
<svg slot="end" style="width: 12px; fill: var(--accent-fill-rest); cursor: pointer;" focusable="false" viewBox="0 0 16 16" aria-hidden="true" blazor:onclick="5"> | ||
<title>Clear</title> | ||
<path d="m2.59 2.72.06-.07a.5.5 0 0 1 .63-.06l.07.06L8 7.29l4.65-4.64a.5.5 0 0 1 .7.7L8.71 8l4.64 4.65c.18.17.2.44.06.63l-.06.07a.5.5 0 0 1-.63.06l-.07-.06L8 8.71l-4.65 4.64a.5.5 0 0 1-.7-.7L7.29 8 2.65 3.35a.5.5 0 0 1-.06-.63l.06-.07-.06.07Z"></path> | ||
</svg> | ||
</fluent-text-field> | ||
</div> |
17 changes: 17 additions & 0 deletions
17
tests/Core/List/FluentAutocompleteTests.FluentAutocomplete_ValueText_Clears.verified.html
This file contains 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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
|
||
<div class=" fluent-autocomplete-multiselect" style="width: 100%;" b-hg72r5b4ox=""> | ||
<fluent-text-field style="width: 100%; min-width: 100%;" placeholder="" id="xxx" value="" current-value="" appearance="outline" blazor:onchange="1" role="combobox" aria-expanded="true" aria-controls="myComponent-popup" aria-label="No items found" blazor:onclick="2" blazor:oninput="3" blazor:onfocusout="4" blazor:elementreference=""> | ||
<svg slot="end" style="width: 16px; fill: var(--accent-fill-rest); cursor: pointer;" focusable="false" viewBox="0 0 16 16" aria-hidden="true" blazor:onclick="6"> | ||
<title>Search</title> | ||
<path d="M9.1 10.17a4.5 4.5 0 1 1 1.06-1.06l3.62 3.61a.75.75 0 1 1-1.06 1.06l-3.61-3.61Zm.4-3.67a3 3 0 1 0-6 0 3 3 0 0 0 6 0Z"></path> | ||
</svg> | ||
</fluent-text-field> | ||
<div class="fluent-overlay" style="cursor: auto; position: fixed; z-index: 9900;" blazor:onclick="7" blazor:oncontextmenu="8" blazor:oncontextmenu:preventdefault="" b-xkrr7evqik=""> | ||
<div style="display: flex; align-items:center; justify-content: center; width: 100%; height: 100%" b-xkrr7evqik=""></div> | ||
</div> | ||
<fluent-anchored-region anchor="xxx" horizontal-positioning-mode="dynamic" horizontal-default-position="right" horizontal-inset="" horizontal-threshold="0" horizontal-scaling="content" vertical-positioning-mode="dynamic" vertical-default-position="unset" vertical-threshold="0" vertical-scaling="content" auto-update-mode="auto" style="z-index: 9999;" b-2ov9fhztky="" blazor:elementreference="xxx"> | ||
<div style="z-index: 9999; background-color: var(--neutral-layer-floating); box-shadow: var(--elevation-shadow-flyout); margin-top: 10px; border-radius: calc(var(--control-corner-radius) * 2px); background-color: var(--neutral-layer-floating);" b-2ov9fhztky=""> | ||
<div id="xxx" role="listbox" style="width: 100%;" tabindex="0" b-hg72r5b4ox=""></div> | ||
</div> | ||
</fluent-anchored-region> | ||
</div> |
Oops, something went wrong.