From ce619bb6561670ffeafdc9600c1cff1fbb388841 Mon Sep 17 00:00:00 2001 From: Kevin Wang Date: Mon, 5 Sep 2022 15:30:07 -0400 Subject: [PATCH 1/5] fix(keybinding): Meta+ArrowDown respects disabled items --- cmdk/src/index.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmdk/src/index.tsx b/cmdk/src/index.tsx index 9551b68..45a7d90 100644 --- a/cmdk/src/index.tsx +++ b/cmdk/src/index.tsx @@ -440,7 +440,7 @@ const Command = React.forwardRef((props, forwarded } } - const last = () => updateSelectedToIndex(state.current.filtered.count - 1) + const last = () => updateSelectedToIndex(getValidItems().length - 1) const next = (e: React.KeyboardEvent) => { e.preventDefault() @@ -593,6 +593,7 @@ const Item = React.forwardRef((props, forwardedRef) = return (
Date: Mon, 5 Sep 2022 15:33:53 -0400 Subject: [PATCH 2/5] chore(keybinds): update test --- test/pages/keybinds.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/pages/keybinds.tsx b/test/pages/keybinds.tsx index 3fe4849..83fa13a 100644 --- a/test/pages/keybinds.tsx +++ b/test/pages/keybinds.tsx @@ -9,6 +9,10 @@ const Page = () => { No results. + + Disabled + + First From 6bb270a192744273390efa67df4d48e5306a3dc3 Mon Sep 17 00:00:00 2001 From: Kevin Wang Date: Mon, 5 Sep 2022 15:35:11 -0400 Subject: [PATCH 3/5] revert id change --- cmdk/src/index.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/cmdk/src/index.tsx b/cmdk/src/index.tsx index 45a7d90..f0d607f 100644 --- a/cmdk/src/index.tsx +++ b/cmdk/src/index.tsx @@ -593,7 +593,6 @@ const Item = React.forwardRef((props, forwardedRef) = return (
Date: Mon, 5 Sep 2022 15:45:24 -0400 Subject: [PATCH 4/5] chore: update test --- test/keybind.test.ts | 2 +- test/pages/keybinds.tsx | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/test/keybind.test.ts b/test/keybind.test.ts index a4dd8c6..ee5a6ba 100644 --- a/test/keybind.test.ts +++ b/test/keybind.test.ts @@ -13,7 +13,7 @@ test.describe('arrow keybinds', async () => { await expect(page.locator(`[cmdk-item][aria-selected="true"]`)).toHaveAttribute('data-value', 'first') }) - test('meta arrow up/down goes to first and last item', async ({ page }) => { + test.only('meta arrow up/down goes to first and last item', async ({ page }) => { await expect(page.locator(`[cmdk-item][aria-selected="true"]`)).toHaveAttribute('data-value', 'first') await page.locator(`[cmdk-input]`).press('Meta+ArrowDown') await expect(page.locator(`[cmdk-item][aria-selected="true"]`)).toHaveAttribute('data-value', 'last') diff --git a/test/pages/keybinds.tsx b/test/pages/keybinds.tsx index 83fa13a..be69dc9 100644 --- a/test/pages/keybinds.tsx +++ b/test/pages/keybinds.tsx @@ -25,10 +25,15 @@ const Page = () => { Apple Banana Orange + Dragon Fruit Pear Last + + + Disabled 3 +
From 0ce9105013bdb33548060a5876dbd866e364a10b Mon Sep 17 00:00:00 2001 From: Paco <34928425+pacocoursey@users.noreply.github.com> Date: Mon, 5 Sep 2022 16:32:26 -0400 Subject: [PATCH 5/5] remove .only --- test/keybind.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/keybind.test.ts b/test/keybind.test.ts index ee5a6ba..a4dd8c6 100644 --- a/test/keybind.test.ts +++ b/test/keybind.test.ts @@ -13,7 +13,7 @@ test.describe('arrow keybinds', async () => { await expect(page.locator(`[cmdk-item][aria-selected="true"]`)).toHaveAttribute('data-value', 'first') }) - test.only('meta arrow up/down goes to first and last item', async ({ page }) => { + test('meta arrow up/down goes to first and last item', async ({ page }) => { await expect(page.locator(`[cmdk-item][aria-selected="true"]`)).toHaveAttribute('data-value', 'first') await page.locator(`[cmdk-input]`).press('Meta+ArrowDown') await expect(page.locator(`[cmdk-item][aria-selected="true"]`)).toHaveAttribute('data-value', 'last')