Repository navigation
fix(desktop): restore macOS zoom in on non-US layouts #30075
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
straumandi
wants to merge
5
commits into
pingdotgg:main
Choose a base branch
from
straumandi:fix/macos-layout-zoom-in
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+109
−0
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ea458f9
fix(desktop): restore macOS zoom in on non-US layouts
straumandi 3dd8001
Merge branch 'main' into fix/macos-layout-zoom-in
straumandi 654cd37
Merge branch 'main' into fix/macos-layout-zoom-in
maria-rcks 6c945f3
Merge remote-tracking branch 'origin/main' into fix/macos-layout-zoom-in
juliusmarminge 3474cba
fix(desktop): let renderer keybindings claim Cmd++ before app zoom
juliusmarminge File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| import type { ResolvedKeybindingsConfig } from "@t3tools/contracts"; | ||
| import { describe, expect, it, vi } from "vite-plus/test"; | ||
|
|
||
| import { registerCommands } from "../shortcuts/dispatcher"; | ||
| import { installDesktopZoomInFallback } from "./desktopZoomInFallback"; | ||
|
|
||
| const previewZoomIn: ResolvedKeybindingsConfig = [ | ||
| { | ||
| command: "preview.zoomIn", | ||
| shortcut: { | ||
| key: "+", | ||
| metaKey: true, | ||
| ctrlKey: false, | ||
| shiftKey: false, | ||
| altKey: false, | ||
| modKey: false, | ||
| }, | ||
| }, | ||
| ]; | ||
|
|
||
| // A German or Swiss layout types "+" on BracketRight without Shift. | ||
| function pressCommandPlus(): KeyboardEvent { | ||
| const event = new KeyboardEvent("keydown", { | ||
| key: "+", | ||
| code: "BracketRight", | ||
| metaKey: true, | ||
| cancelable: true, | ||
| bubbles: true, | ||
| }); | ||
| window.dispatchEvent(event); | ||
| return event; | ||
| } | ||
|
|
||
| describe("installDesktopZoomInFallback", () => { | ||
| it("zooms the app only when no keybinding consumed Cmd++", () => { | ||
| const zoomAppIn = vi.fn(async () => {}); | ||
| const previewZoom = vi.fn(); | ||
| using stack = new DisposableStack(); | ||
| stack.defer(installDesktopZoomInFallback({ zoomAppIn }, "MacIntel") ?? (() => {})); | ||
|
|
||
| expect(pressCommandPlus().defaultPrevented).toBe(true); | ||
| expect(zoomAppIn).toHaveBeenCalledOnce(); | ||
|
|
||
| stack.defer( | ||
| registerCommands( | ||
| { "preview.zoomIn": previewZoom }, | ||
| { keybindings: () => previewZoomIn, context: () => ({ previewFocus: true }) }, | ||
| ), | ||
| ); | ||
| pressCommandPlus(); | ||
| expect(previewZoom).toHaveBeenCalledOnce(); | ||
| expect(zoomAppIn).toHaveBeenCalledOnce(); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| import type { DesktopBridge } from "@t3tools/contracts"; | ||
| import { isMacPlatform } from "@t3tools/shared/keybindings"; | ||
|
|
||
| import { registerCommands } from "../shortcuts/dispatcher"; | ||
|
|
||
| /** | ||
| * macOS matches the Zoom In menu shortcut by US key position, so Cmd++ does nothing on layouts | ||
| * with "+" elsewhere. Zoom the app when no keybinding (such as preview zoom) consumed the key. | ||
| */ | ||
| export function installDesktopZoomInFallback( | ||
| bridge: Pick<DesktopBridge, "zoomAppIn"> | undefined, | ||
| platform: string, | ||
| ): (() => void) | undefined { | ||
| if (!bridge || !isMacPlatform(platform)) return undefined; | ||
| return registerCommands( | ||
| {}, | ||
| { | ||
| observe: (event, consumed) => { | ||
| if (consumed || !event.metaKey || event.ctrlKey || event.altKey || event.key !== "+") { | ||
| return; | ||
| } | ||
| // Keeps the US-layout menu accelerator from zooming a second time. | ||
| event.preventDefault(); | ||
| void bridge.zoomAppIn(); | ||
| }, | ||
| }, | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Script executed:
Repository: pingdotgg/t3code
Length of output: 4940
Script executed:
Repository: pingdotgg/t3code
Length of output: 20700
Script executed:
Repository: pingdotgg/t3code
Length of output: 20638
Add a focused test for the zoom IPC handler.
In
apps/desktop/src/ipc/methods/window.test.ts, test that the main-window sender zooms in and a different sender does not. The browser test mockszoomAppIn, so it cannot detect a regression in the sender check or desktop delegation.