Skip to content

Commit 6123369

Browse files
authored
fix(suite): fix draggable window header (#16437)
* fix(suite): fix draggable window header * fix(suite): Move window dragging area to Main in suite-desktop
1 parent 1709321 commit 6123369

File tree

5 files changed

+26
-19
lines changed

5 files changed

+26
-19
lines changed

packages/components/src/components/NewModal/NewModal.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ const Container = styled.div<
5656
overflow: hidden;
5757
background: ${mapElevationToBackground};
5858
box-shadow: ${({ theme }) => theme.boxShadowElevated};
59+
-webkit-app-region: no-drag;
5960
6061
${withFrameProps}
6162
`;

packages/suite-desktop-ui/src/Main.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import TrezorConnect from '@trezor/connect';
1414
import { initStore } from 'src/reducers/store';
1515
import { preloadStore } from 'src/support/suite/preloadStore';
1616
import { Metadata } from 'src/components/suite/Metadata';
17-
import { Preloader, ToastContainer } from 'src/components/suite';
17+
import { Preloader, ToastContainer, TrafficLightDraggableWindowHeader } from 'src/components/suite';
1818
import { ConnectedIntlProvider } from 'src/support/suite/ConnectedIntlProvider';
1919
import Resize from 'src/support/suite/Resize';
2020
import Autodetect from 'src/support/suite/Autodetect';
@@ -45,6 +45,7 @@ const Main = () => {
4545
// Todo: Enable when issues are fixed (ReactTruncate & BumpFee)
4646
// <StrictMode>
4747
<HelmetProvider>
48+
<TrafficLightDraggableWindowHeader />
4849
<ConnectedThemeProvider>
4950
<RouterProvider history={history}>
5051
<ModalContextProvider>

packages/suite/src/components/suite/TrafficLightOffset.tsx

+15-17
Original file line numberDiff line numberDiff line change
@@ -11,42 +11,40 @@ type Props = {
1111
isVisible?: boolean;
1212
};
1313

14-
// See: https://github.com/electron/electron/issues/5678
15-
// Visible all the time in the app
16-
const ThinFixForNotBeingAbleToDragWindow = styled.div`
14+
const FixForNotBeingAbleToDragWindow = styled.div`
1715
-webkit-app-region: drag;
18-
height: 16px;
16+
pointer-events: none;
17+
height: 64px;
1918
position: fixed;
2019
z-index: ${zIndices.windowControls};
2120
top: 0;
2221
left: 0;
2322
width: 100%;
2423
`;
2524

26-
// Visible below content (but visible in the sidebar)
27-
const ThickFixForNotBeingAbleToDragWindow = styled(ThinFixForNotBeingAbleToDragWindow)`
28-
height: 64px;
29-
z-index: unset;
30-
`;
31-
3225
const Container = styled.div<{ $offset: number }>`
3326
${({ $offset }) => `padding-top: ${$offset}px;`}
3427
width: 100%;
3528
height: 100%;
3629
`;
3730

31+
// See: https://github.com/electron/electron/issues/5678
32+
// Visible all the time in the app
33+
export const TrafficLightDraggableWindowHeader = ({ children, isVisible = true }: Props) => {
34+
const isMac = isMacOs();
35+
const isDesktopApp = isDesktop();
36+
37+
if (!isVisible || !isMac || !isDesktopApp) return children;
38+
39+
return <FixForNotBeingAbleToDragWindow />;
40+
};
41+
3842
// on Mac in desktop app we don't use window bar and close/maximize/minimize icons are positioned directly in the app
3943
export const TrafficLightOffset = ({ children, offset = 35, isVisible = true }: Props) => {
4044
const isMac = isMacOs();
4145
const isDesktopApp = isDesktop();
4246

4347
if (!isVisible || !isMac || !isDesktopApp) return children;
4448

45-
return (
46-
<>
47-
<ThinFixForNotBeingAbleToDragWindow />
48-
<ThickFixForNotBeingAbleToDragWindow />
49-
<Container $offset={offset}>{children}</Container>
50-
</>
51-
);
49+
return <Container $offset={offset}>{children}</Container>;
5250
};

packages/suite/src/components/suite/index.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ import { QrCode } from './QrCode';
4747
import { CoinBalance } from './CoinBalance';
4848
import { DeviceAuthenticationExplainer } from './DeviceAuthenticationExplainer';
4949
import { Preloader } from './Preloader/Preloader';
50+
import { TrafficLightDraggableWindowHeader } from './TrafficLightOffset';
5051
import { PinMatrix } from './PinMatrix/PinMatrix';
5152
import { UdevDownload } from './UdevDownload';
5253
import { StakingFeature } from './StakingFeature';
@@ -100,6 +101,7 @@ export {
100101
CoinBalance,
101102
DeviceAuthenticationExplainer,
102103
Preloader,
104+
TrafficLightDraggableWindowHeader,
103105
PinMatrix,
104106
UdevDownload,
105107
StakingFeature,

packages/suite/src/views/suite/SwitchDevice/SwitchDeviceModal.tsx

+6-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ type SwitchDeviceModalProps = {
1717

1818
const Container = styled.div`
1919
width: 378px;
20+
-webkit-app-region: no-drag;
2021
`;
2122

2223
const initial = {
@@ -51,7 +52,11 @@ export const SwitchDeviceModal = ({
5152
width: 369,
5253
height: 'auto',
5354
}}
54-
style={{ originX: 0, originY: 0, overflow: 'hidden' }}
55+
style={{
56+
originX: 0,
57+
originY: 0,
58+
overflow: 'hidden',
59+
}}
5560
>
5661
{children}
5762
</motion.div>

0 commit comments

Comments
 (0)