Skip to content

Commit 2a6e2c0

Browse files
feat(web): swap u and i focus shortcuts for right sidebar (#2321)
* feat(web): swap u and i focus shortcuts for right sidebar With the sidebar on the right, I focuses the sidebar and U focuses the grid so keyboard layout matches the UI. Co-authored-by: Cursor <cursoragent@cursor.com> * test(e2e): update sidebar focus shortcut from u to i Co-authored-by: Cursor <cursoragent@cursor.com> --------- Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 4a6f25f commit 2a6e2c0

9 files changed

Lines changed: 28 additions & 28 deletions

File tree

docs/acceptance/shortcuts.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ Helpful notes:
4747
| `J` | Day view | Previous day |
4848
| `K` | Day view | Next day |
4949
| `T` | Day view | Go to today |
50-
| `U` | Day view | Focus sidebar |
51-
| `I` | Day view | Focus calendar |
50+
| `I` | Day view | Focus sidebar |
51+
| `U` | Day view | Focus calendar |
5252
| `C` | Day view | Create timed event |
5353
| `A` | Day view | Create all-day event |
5454
| `Shift+ArrowUp` / `Shift+ArrowDown` | Day view | Move focused timed event 15 min earlier/later |
@@ -57,8 +57,8 @@ Helpful notes:
5757
| `T` | Week view | Go to today |
5858
| `C` | Week view | Create timed event |
5959
| `A` | Week view | Create all-day event |
60-
| `U` | Week view | Focus sidebar |
61-
| `I` | Week view | Focus first calendar event |
60+
| `I` | Week view | Focus sidebar |
61+
| `U` | Week view | Focus first calendar event |
6262
| `Delete` | Week view | Delete focused/hovered event |
6363
| `Shift+ArrowLeft` | Week view | Move focused event to previous day |
6464
| `Shift+ArrowRight` | Week view | Move focused event to next day |

e2e/accessibility/focus-visible.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ import {
55
} from "../utils/event-test-utils";
66

77
// Regression guard for "feat(web): ensure all focus areas have visible
8-
// feedback". The "u" shortcut used to move focus into the sidebar with no
8+
// feedback". The "i" shortcut used to move focus into the sidebar with no
99
// visible indicator (it landed on a month-nav chevron that had no focus
1010
// style, and a global outline reset stripped the fallback). It now lands on
1111
// the month picker's tab-stoppable day, which shows an accent focus ring.
12-
test("the 'u' shortcut moves focus to a visibly-focused sidebar day", async ({
12+
test("the 'i' shortcut moves focus to a visibly-focused sidebar day", async ({
1313
page,
1414
}) => {
1515
await prepareCalendarPage(page);
@@ -18,7 +18,7 @@ test("the 'u' shortcut moves focus to a visibly-focused sidebar day", async ({
1818
// A real (trusted) keypress so :focus-visible resolves as it would for a
1919
// keyboard user, and so the app's keyup shortcut handler fires.
2020
await page.locator("#mainGrid").focus();
21-
await page.keyboard.press("u");
21+
await page.keyboard.press("i");
2222

2323
const focused = page.locator(".react-datepicker__day:focus");
2424
await expect(focused).toBeVisible();

packages/web/src/shortcuts/data/shortcuts.data.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,12 @@ describe("shortcuts.data", () => {
123123
);
124124

125125
expect(findFocus("day")?.shortcuts).toEqual([
126-
{ keys: ["u"], label: "Focus sidebar" },
127-
{ keys: ["i"], label: "Focus calendar" },
126+
{ keys: ["i"], label: "Focus sidebar" },
127+
{ keys: ["u"], label: "Focus calendar" },
128128
]);
129129
expect(findFocus("week")?.shortcuts).toEqual([
130-
{ keys: ["u"], label: "Focus sidebar" },
131-
{ keys: ["i"], label: "Focus calendar event" },
130+
{ keys: ["i"], label: "Focus sidebar" },
131+
{ keys: ["u"], label: "Focus calendar event" },
132132
]);
133133
});
134134

packages/web/src/shortcuts/data/shortcuts.data.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,12 @@ const getFocusShortcuts = (view: ShortcutMenuView): Shortcut[] =>
6565
? []
6666
: view === "day"
6767
? [
68-
{ keys: ["u"], label: "Focus sidebar" },
69-
{ keys: ["i"], label: "Focus calendar" },
68+
{ keys: ["i"], label: "Focus sidebar" },
69+
{ keys: ["u"], label: "Focus calendar" },
7070
]
7171
: [
72-
{ keys: ["u"], label: "Focus sidebar" },
73-
{ keys: ["i"], label: "Focus calendar event" },
72+
{ keys: ["i"], label: "Focus sidebar" },
73+
{ keys: ["u"], label: "Focus calendar event" },
7474
];
7575

7676
const getEditShortcuts = (view: ShortcutMenuView): Shortcut[] =>

packages/web/src/views/Day/hooks/shortcuts/useDayViewShortcuts.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@ describe("useDayViewShortcuts create", () => {
6060
});
6161

6262
describe("useDayViewShortcuts focus", () => {
63-
it("focuses the sidebar with U", async () => {
63+
it("focuses the sidebar with I", async () => {
6464
const onFocusSidebar = mock();
6565

6666
renderHook(() => useDayViewShortcuts({ onFocusSidebar }), { wrapper });
67-
pressKey("U");
67+
pressKey("I");
6868

6969
await waitFor(() => {
7070
expect(onFocusSidebar).toHaveBeenCalled();

packages/web/src/views/Day/hooks/shortcuts/useDayViewShortcuts.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ interface KeyboardShortcutsConfig {
2222
* Hook to handle keyboard shortcuts for the Day view.
2323
*
2424
* Mirrors the Week view's create/focus semantics: "c" creates a timed event,
25-
* "a" an all-day event, "u" focuses the sidebar, "i" the calendar.
25+
* "a" an all-day event, "i" focuses the sidebar, "u" the calendar.
2626
*/
2727
export function useDayViewShortcuts(config: KeyboardShortcutsConfig) {
2828
const {
@@ -48,7 +48,7 @@ export function useDayViewShortcuts(config: KeyboardShortcutsConfig) {
4848
});
4949

5050
useAppShortcutUp("U", () => {
51-
onFocusSidebar?.();
51+
onFocusCalendar?.();
5252
});
5353

5454
useAppShortcutUp("C", () => {
@@ -66,8 +66,8 @@ export function useDayViewShortcuts(config: KeyboardShortcutsConfig) {
6666
blurOnTrigger: true,
6767
});
6868

69-
// Calendar shortcuts
69+
// Sidebar shortcuts
7070
useAppShortcutUp("I", () => {
71-
onFocusCalendar?.();
71+
onFocusSidebar?.();
7272
});
7373
}

packages/web/src/views/Day/view/DayViewContent.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export const DayViewContent = memo(() => {
5959
viewActions.toggleSidebar();
6060
}, []);
6161

62-
// "u" implies the user wants the sidebar; open it first and defer focus a
62+
// "i" implies the user wants the sidebar; open it first and defer focus a
6363
// frame so the sidebar exists in the DOM before we target it.
6464
const handleFocusSidebar = useCallback(() => {
6565
if (selectIsSidebarOpen(useViewStore.getState())) {

packages/web/src/views/Week/hooks/shortcuts/useWeekShortcuts.test.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,11 +233,11 @@ describe("useWeekShortcuts day shifting", () => {
233233
});
234234

235235
describe("useWeekShortcuts calendar event targeting", () => {
236-
it("focuses the first visible calendar event with I", async () => {
236+
it("focuses the first visible calendar event with U", async () => {
237237
const button = addCalendarTarget();
238238

239239
renderShortcuts();
240-
pressKey("I");
240+
pressKey("U");
241241

242242
await waitFor(() => {
243243
expect(document.activeElement).toBe(button);
@@ -566,11 +566,11 @@ const addSidebarFixture = (options?: { includeItem?: boolean }) => {
566566
};
567567

568568
describe("useWeekShortcuts sidebar focus", () => {
569-
it("focuses the first interactive sidebar item with U", async () => {
569+
it("focuses the first interactive sidebar item with I", async () => {
570570
const { weekItem } = addSidebarFixture({ includeItem: true });
571571

572572
renderShortcuts();
573-
pressKey("U");
573+
pressKey("I");
574574

575575
await waitFor(() => {
576576
expect(document.activeElement).toBe(weekItem);

packages/web/src/views/Week/hooks/shortcuts/useWeekShortcuts.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,8 +336,8 @@ export const useWeekShortcuts = ({
336336
useAppShortcutUp("T", toToday);
337337
useAppShortcutUp("A", createAllDayDraftEvent);
338338
useAppShortcutUp("C", createTimedDraftEvent);
339-
useAppShortcutUp("U", focusSidebar);
340-
useAppShortcutUp("I", focusFirstCalendarEvent);
339+
useAppShortcutUp("I", focusSidebar);
340+
useAppShortcutUp("U", focusFirstCalendarEvent);
341341
useAppShortcut("Delete", deleteTargetedCalendarEvent, {
342342
ignoreInputs: false,
343343
});

0 commit comments

Comments
 (0)