From 218c6bd639adc02f22c362c1c5fff842b68c28dd Mon Sep 17 00:00:00 2001 From: Fabien MARIE-LOUISE Date: Tue, 25 Apr 2023 13:16:50 +0200 Subject: [PATCH] chore: changeset v0.9.3 --- .changeset/ninety-singers-obey.md | 9 ++ apps/docs/src/VERSIONS.ts | 1 + apps/docs/src/routes/docs/changelog/0-9-1.mdx | 2 +- apps/docs/src/routes/docs/changelog/0-9-3.mdx | 9 ++ packages/core/src/combobox/combobox-base.tsx | 25 ------ packages/core/src/select/select.test.tsx | 86 +++++++++++++++++++ 6 files changed, 106 insertions(+), 26 deletions(-) create mode 100644 .changeset/ninety-singers-obey.md create mode 100644 apps/docs/src/routes/docs/changelog/0-9-3.mdx diff --git a/.changeset/ninety-singers-obey.md b/.changeset/ninety-singers-obey.md new file mode 100644 index 00000000..8c89e40d --- /dev/null +++ b/.changeset/ninety-singers-obey.md @@ -0,0 +1,9 @@ +--- +"@kobalte/core": patch +--- + +## Bug fixes + +- [#187](https://github.com/kobaltedev/kobalte/pull/187) +- [#188](https://github.com/kobaltedev/kobalte/pull/188) +- [#191](https://github.com/kobaltedev/kobalte/pull/191) diff --git a/apps/docs/src/VERSIONS.ts b/apps/docs/src/VERSIONS.ts index 1e454f73..7a166ff4 100644 --- a/apps/docs/src/VERSIONS.ts +++ b/apps/docs/src/VERSIONS.ts @@ -19,6 +19,7 @@ export const CORE_VERSIONS = [ "0.9.0", "0.9.1", "0.9.2", + "0.9.3", ].reverse(); export const LATEST_CORE_CHANGELOG_URL = `/docs/changelog/${CORE_VERSIONS[0].replaceAll(".", "-")}`; diff --git a/apps/docs/src/routes/docs/changelog/0-9-1.mdx b/apps/docs/src/routes/docs/changelog/0-9-1.mdx index 50b27123..9c3c74b5 100644 --- a/apps/docs/src/routes/docs/changelog/0-9-1.mdx +++ b/apps/docs/src/routes/docs/changelog/0-9-1.mdx @@ -1,6 +1,6 @@ # v0.9.1 -**April 25, 2023**. +**April 24, 2023**. ## Bug fixes diff --git a/apps/docs/src/routes/docs/changelog/0-9-3.mdx b/apps/docs/src/routes/docs/changelog/0-9-3.mdx new file mode 100644 index 00000000..a70d66c1 --- /dev/null +++ b/apps/docs/src/routes/docs/changelog/0-9-3.mdx @@ -0,0 +1,9 @@ +# v0.9.3 + +**April 25, 2023**. + +## Bug fixes + +- [#187](https://github.com/kobaltedev/kobalte/pull/187) +- [#188](https://github.com/kobaltedev/kobalte/pull/188) +- [#191](https://github.com/kobaltedev/kobalte/pull/191) diff --git a/packages/core/src/combobox/combobox-base.tsx b/packages/core/src/combobox/combobox-base.tsx index fa117c68..e4b5921c 100644 --- a/packages/core/src/combobox/combobox-base.tsx +++ b/packages/core/src/combobox/combobox-base.tsx @@ -300,7 +300,6 @@ export function ComboboxBase(props: ComboboxBaseProps< const [isInputFocused, setIsInputFocusedState] = createSignal(false); const [lastDisplayedOptions, setLastDisplayedOptions] = createSignal(local.options); - //const [selectedOptions, setSelectedOptions] = createSignal>([]); const messageFormatter = createMessageFormatter(() => COMBOBOX_INTL_MESSAGES); @@ -559,30 +558,6 @@ export function ComboboxBase(props: ComboboxBaseProps< } }); - // Create a copy of the selected options when selection changes - // Prevent displayed selection from disappearing when filtering the options. - /* - createEffect( - on( - () => listState.selectionManager().selectedKeys(), - selectedKeys => { - setSelectedOptions(prev => { - const optionsToKeep = prev.filter(option => selectedKeys.has(getOptionValue(option))); - - const keysToKeep = optionsToKeep.map(option => getOptionValue(option)); - - const newKeysToAdd = [...selectedKeys].filter(key => !keysToKeep.includes(key)); - - return [ - ...optionsToKeep, - ...getOptionsFromValues(new Set(newKeysToAdd)).filter(option => option != null), - ]; - }); - } - ) - ); - */ - // VoiceOver has issues with announcing aria-activedescendant properly on change. // We use a live region announcer to announce focus changes manually. let lastAnnouncedFocusedKey = ""; diff --git a/packages/core/src/select/select.test.tsx b/packages/core/src/select/select.test.tsx index 9608b4e3..c3a7117c 100644 --- a/packages/core/src/select/select.test.tsx +++ b/packages/core/src/select/select.test.tsx @@ -2813,6 +2813,92 @@ describe("Select", () => { expect(onValueChange.mock.calls[0][0].includes(DATA_SOURCE[2])).toBeTruthy(); }); + it("should keep the selection order", async () => { + render(() => ( + ( + {props.item.rawValue.label} + )} + > + Label + + > + {({ selectedOptions }) => + selectedOptions() + .map(opt => opt.label) + .join(", ") + } + + + + + + + + + )); + + const trigger = screen.getByRole("button"); + expect(trigger).toHaveTextContent("Placeholder"); + + fireEvent(trigger, createPointerEvent("pointerdown", { pointerId: 1, pointerType: "mouse" })); + await Promise.resolve(); + + fireEvent(trigger, createPointerEvent("pointerup", { pointerId: 1, pointerType: "mouse" })); + await Promise.resolve(); + + jest.runAllTimers(); + + const listbox = screen.getByRole("listbox"); + const items = within(listbox).getAllByRole("option"); + + expect(listbox).toHaveAttribute("aria-multiselectable", "true"); + + expect(items.length).toBe(3); + expect(items[0]).toHaveTextContent("One"); + expect(items[1]).toHaveTextContent("Two"); + expect(items[2]).toHaveTextContent("Three"); + + expect(document.activeElement).toBe(listbox); + + fireEvent( + items[2], + createPointerEvent("pointerdown", { pointerId: 1, pointerType: "mouse" }) + ); + await Promise.resolve(); + + fireEvent(items[2], createPointerEvent("pointerup", { pointerId: 1, pointerType: "mouse" })); + await Promise.resolve(); + + fireEvent( + items[0], + createPointerEvent("pointerdown", { pointerId: 1, pointerType: "mouse" }) + ); + await Promise.resolve(); + + fireEvent(items[0], createPointerEvent("pointerup", { pointerId: 1, pointerType: "mouse" })); + await Promise.resolve(); + + expect(items[0]).toHaveAttribute("aria-selected", "true"); + expect(items[2]).toHaveAttribute("aria-selected", "true"); + + expect(onValueChange).toBeCalledTimes(2); + expect(onValueChange.mock.calls[0][0].includes(DATA_SOURCE[2])).toBeTruthy(); + expect(onValueChange.mock.calls[1][0].includes(DATA_SOURCE[0])).toBeTruthy(); + + // Does not close on multi-select + expect(listbox).toBeVisible(); + + expect(trigger).toHaveTextContent("Three, One"); + }); + it("supports deselection", async () => { const defaultValue = [DATA_SOURCE[0], DATA_SOURCE[1]];