Skip to content

Commit

Permalink
fix(console): prevent default zoom behavior (#6854)
Browse files Browse the repository at this point in the history
Prevent the default zoom behavior everywhere in the app.

Since the explorer panel handles the zoom manually, sometimes users may end up zooming the whole app by mistake and end up with the explorer panel covering the whole screen.

This is a big problem since users won't be able to zoom out of it.
  • Loading branch information
skyrpex authored Jul 5, 2024
1 parent 7a0ea6f commit 08d367e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
5 changes: 4 additions & 1 deletion apps/wing-console/console/app/web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/x-icon" href="./favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta
name="viewport"
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"
/>
<title>Wing Console</title>
<link rel="stylesheet" href="./index.css" />
</head>
Expand Down
17 changes: 17 additions & 0 deletions apps/wing-console/console/ui/src/Console.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
import type { Mode } from "@wingconsole/design-system";
import type { Trace } from "@wingconsole/server";
import { useEffect, useMemo, useState } from "react";
import { useEvent } from "react-use";

import { App } from "./App.js";
import { AppContext } from "./AppContext.js";
Expand Down Expand Up @@ -138,6 +139,22 @@ export const Console = ({
};
}, [layout]);

// Prevent the default zoom behavior everywhere in the app.
// Since the explorer panel handles the zoom manually, sometimes
// users may end up zooming the whole app by mistake and end up
// with the explorer panel covering the whole screen. This is
// a big problem since users won't be able to zoom out of it.
useEvent(
"wheel",
(event) => {
if ((event as WheelEvent).ctrlKey) {
event.preventDefault();
}
},
document,
{ passive: false },
);

return (
<AppContext.Provider
value={{
Expand Down

0 comments on commit 08d367e

Please sign in to comment.