fix(ui): honor select search limits for large regional lists

This commit is contained in:
Clintchiz committed 2026-08-26 17:46:13 +05:30
1 parent b1b84eb41c
commit 9e0907ffb2
5 files changed
+84 -4

No files matched your search

+2 -2
View File
@@ -375,7 +375,7 @@ component AdvancedSelect {
{#if visibleOptions(group.options || []).length}
<div class="wrn-next__option-group" role="group" aria-label="{group.label}">
<div class="wrn-next__group-label">{group.label}</div>
{#each group.options || [] as option}
{#each visibleOptions(group.options || []) as option}
<button
type="button"
class="wrn-next__select-option {isSelected(option) ? 'wrn-next__select-option--selected' : ''} {optionIndex(option) === activeIndex ? 'wrn-next__select-option--active' : ''}"
@@ -402,7 +402,7 @@ component AdvancedSelect {
{/if}
{/each}
{#each options as option}
{#each visibleOptions(options) as option}
<button
type="button"
class="wrn-next__select-option {isSelected(option) ? 'wrn-next__select-option--selected' : ''} {optionIndex(option) === activeIndex ? 'wrn-next__select-option--active' : ''}"
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@wrnexus/ui",
"version": "0.8.59",
"version": "0.8.60",
"private": true,
"type": "module",
"main": "src/index.ts",
+20
View File
@@ -1890,6 +1890,26 @@ test("input number increments, decrements, applies steps, and respects limits",
expect(decrement().disabled).toBe(true);
});
test("advanced select limits rendered options but searches the full dataset and retains saved values", async () => {
const source = readFileSync(uiComponentPath("AdvancedSelect"), "utf8");
const dom = mountHtml(
await renderComponent(source, {
name: "region",
value: "99",
searchResultLimit: 4,
options: Array.from({ length: 100 }, (_, i) => ({ value: String(i), label: "Region " + i })),
}),
);
expect(dom.querySelector(".wrn-next__select-value")?.textContent).toContain("Region 99");
expect(dom.querySelectorAll(".wrn-next__select-option")).toHaveLength(4);
(dom.querySelector(".wrn-next__select-trigger") as HTMLButtonElement).click();
const search = dom.querySelector('input[type="search"]') as HTMLInputElement;
search.value = "Region 99";
search.dispatchEvent(new (dom.window as any).Event("input", { bubbles: true }));
expect(dom.querySelectorAll(".wrn-next__select-option")).toHaveLength(1);
expect(dom.querySelector(".wrn-next__select-option")?.textContent).toContain("Region 99");
});
test("advanced select opens, filters, and selects without reactive handler errors", async () => {
const source = readFileSync(uiComponentPath("AdvancedSelect"), "utf8");
const html = await renderComponent(source, {