fix(web): right panel shortcuts on non-Latin layouts and terminal close dialog UX #13428
Closedartile(GitHub profile, opens in a new tab)wants to merge 6 commits into
main fromrefs/pull/13428/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
- @@ -247,13 +247,17 @@247247 KeyboardEvent,248248 "altKey" | "ctrlKey" | "defaultPrevented" | "isComposing" | "key" | "metaKey"249->;249+> & { readonly code?: string };250250251251 export function surfaceShortcutActionForKey<252252 const Action extends { available: boolean; shortcut: string },253253 >(actions: readonly Action[], event: SurfaceShortcutEvent): Action | null {254254 if (event.defaultPrevented || event.isComposing) return null;255255 if (event.metaKey || event.ctrlKey || event.altKey) return null;256+ const layoutKey = event.key.toLowerCase();257+ const letterCode = event.code?.match(/^Key([A-Z])$/)?.[1]?.toLowerCase();256258 return (257- actions.find(258- (action) => action.available && action.shortcut.toLowerCase() === event.key.toLowerCase(),259- ) ?? null259+ actions.find((action) => {260+ if (!action.available) return false;261+ const targetShortcut = action.shortcut.toLowerCase();262+ if (targetShortcut === layoutKey) return true;263+ if (letterCode && !/^[a-z]$/.test(layoutKey) && targetShortcut === letterCode) return true;@@ -76,18 +171,5 @@76171 }}77172 >78- <AlertDialogPopup>79- <AlertDialogHeader>80- <AlertDialogTitle>{copy.title}</AlertDialogTitle>81- {copy.description ? (82- <AlertDialogDescription className="whitespace-pre-line">83- {copy.description}84- </AlertDialogDescription>85- ) : null}86- </AlertDialogHeader>87- <AlertDialogFooter>88- <AlertDialogClose render={<Button variant="outline" />}>Cancel</AlertDialogClose>89- <Button variant={confirmVariant} onClick={onConfirm}>90- Confirm91- </Button>92- </AlertDialogFooter>93- </AlertDialogPopup>173+ {isMounted ? (174+ <ConfirmDialogBody175+ key={state.message}@@ -1405,3 +1422,4 @@14051422 <div className="flex min-h-0 flex-1 flex-col" data-right-panel-surface-content>14061423 {props.activeSurfaceId === null ? (14071424 <RightPanelEmptyState1425+ open={props.open}
- apps/web/src/components/ConfirmDialogHost.tsx line 175OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -76,18 +171,5 @@76171 }}77172 >78- <AlertDialogPopup>79- <AlertDialogHeader>80- <AlertDialogTitle>{copy.title}</AlertDialogTitle>81- {copy.description ? (82- <AlertDialogDescription className="whitespace-pre-line">83- {copy.description}84- </AlertDialogDescription>85- ) : null}86- </AlertDialogHeader>87- <AlertDialogFooter>88- <AlertDialogClose render={<Button variant="outline" />}>Cancel</AlertDialogClose>89- <Button variant={confirmVariant} onClick={onConfirm}>90- Confirm91- </Button>92- </AlertDialogFooter>93- </AlertDialogPopup>173+ {isMounted ? (174+ <ConfirmDialogBody175+ key={state.message}apps/web/src/components/RightPanelTabs.tsx line 442OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -421,3 +428,15 @@421428 const highlightIndex =422429 availableActions.length === 0 ? -1 : Math.min(highlight, availableActions.length - 1);423430431+ // Letter shortcuts work while the launcher is visible, not only while it432+ // is focused; focus moves around too easily (stray clicks) to carry them.433+ // Capture phase so app-level key handlers cannot swallow the event first;434+ // typing contexts and already-handled events are left alone.435+ const isPanelOpen = props.open !== false;436+ const containerRef = useRef<HTMLDivElement | null>(null);437+438+ useEffect(() => {439+ if (isPanelOpen) {440+ containerRef.current?.focus();441+ }442+ }, [isPanelOpen, shortcutActionsRef]);apps/web/src/components/settings/SettingsPanels.tsx lines 627 to 629Resolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -621,3 +621,6 @@621621 ...(settings.confirmThreadDelete !== DEFAULT_UNIFIED_SETTINGS.confirmThreadDelete622622 ? ["Delete confirmation"]623623 : []),624+ ...(settings.confirmTerminalClose !== DEFAULT_UNIFIED_SETTINGS.confirmTerminalClose625+ ? ["Terminal close confirmation"]626+ : []),apps/web/src/lib/terminalCloseConfirm.ts lines 50 to 60Resolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -32,5 +37,17 @@3237 .map((label) => `"${label}"`)3338 .join(", ")}.`,3439 ].join("\n"),35- { variant: "destructive" },40+ {41+ variant: "destructive",42+ checkbox: {43+ label: "Don't ask again",44+ onCheckedChange: (checked) => {45+ dontAskAgain = checked;46+ },47+ },48+ },3649 );50+ if (confirmed && dontAskAgain) {51+ void persistClientSettingsPatch({ confirmTerminalClose: false });52+ }53+ return confirmed;
- apps/web/src/lib/terminalCloseConfirm.ts lines 48 to 61Resolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -33,5 +38,20 @@3338 .join(", ")}.`,3439 ].join("\n"),35- { variant: "destructive" },40+ {41+ variant: "destructive",42+ checkbox: {43+ label: "Don't ask again",44+ onCheckedChange: (checked) => {45+ dontAskAgain = checked;46+ },47+ },48+ },3649 );50+ if (confirmed && dontAskAgain) {51+ await persistClientSettingsUpdate((settings) => ({52+ ...settings,53+ confirmTerminalClose: false,54+ }));55+ }56+ return confirmed;3757 } catch {
juliusmarminge closed this
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) reviewed