Skip to content

Fix: Topbar icons display padding in macOS fullscreen - #833

Merged
bcotrim merged 3 commits into
trunkfrom
fix/sidebar_toggle_large_screens
Jan 27, 2025
Merged

Fix: Topbar icons display padding in macOS fullscreen#833
bcotrim merged 3 commits into
trunkfrom
fix/sidebar_toggle_large_screens

Conversation

@bcotrim

@bcotrim bcotrim commented Jan 22, 2025

Copy link
Copy Markdown
Contributor

Related issues

Proposed Changes

  • Added smooth transitions for window controls positioning when entering/exiting full-screen mode
  • Implemented native full-screen state detection through Electron's IPC
  • Added proper event handling for full-screen state changes in the main window

Testing Instructions

  1. Launch the application
  2. Verify window topbar controls are properly positioned based on system language direction
  3. Enter full-screen mode (⌘+Control+F or green window button)
    • Verify smooth transition of window topbar controls
    • Confirm correct padding in full-screen mode
  4. Exit full-screen mode
    • Verify smooth transition back to windowed mode
    • Confirm window topbar controls return to correct position
  5. Repeat tests with both LTR and RTL language settings

Expected Behavior

  • Window topbar controls should smoothly transition when entering/exiting full-screen
  • Padding should adjust correctly based on window state and language direction
  • No visual glitches or jumps during transitions
  • Consistent behavior in both LTR and RTL

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?
@bcotrim
bcotrim marked this pull request as ready for review January 23, 2025 15:09
@bcotrim
bcotrim requested a review from a team January 23, 2025 15:10

@katinthehatsite katinthehatsite left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!

I like the effect it creates when the window becomes full-size 👍

One thing that I find a bit strange is when you go from the full size window to the smaller window and for a couple of seconds while the transition is happening, the buttons are overlapping the sidebar toggle. I could see this happening both with either buttons or key board shortcuts. I tried to capture it in the video below. Hopefully it illustrates well what I mean but let me know if I am not explaining this well.

Screen.Recording.2025-01-23.at.5.25.12.PM.mov

I am not sure if there is an easy solution for this though. Perhaps this is okay.

Everything worked well on my end for rtl and ltr languages.

import { renderHook } from '@testing-library/react';
import { act } from 'react';
import { getIpcApi } from '../../lib/get-ipc-api';
import { useFullscreen } from '../use-fullscreen';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thanks for adding tests!

@fredrikekelund fredrikekelund left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍 I agree with @katinthehatsite that it would be nice if the transition ran earlier, but looking at when the enter-full-screen and leave-full-screen events are fired, that seems difficult to pull off. I also couldn't find any other viable methods for listening to earlier events about fullscreen state changes, so we may just have to accept that small nuisance.

Comment thread src/components/mac-titlebar.tsx Outdated
// Leave space for window controls depending on which side they are on
// Take into account the "chrome" padding, the position of which depends on the language direction
isWindowFrameRtl() &&
'transition-[padding] duration-700 ease-in-out',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'transition-[padding] duration-700 ease-in-out',
'transition-[padding] duration-500 ease-in-out',

I would speed up this animation slightly. 500ms matches the sidebar transition

Comment thread src/hooks/tests/use-fullscreen.test.ts Outdated
Comment on lines +27 to +29
await act( async () => {
await Promise.resolve();
} );

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
await act( async () => {
await Promise.resolve();
} );
await waitFor( () => {
expect( mockIpcApi.isFullscreen ).toHaveBeenCalledTimes( 1 );
} );

Optional, but I found the current code a bit cryptic. I think this clarifies the intention.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much cleaner approach, thank you!

Comment thread src/hooks/tests/use-fullscreen.test.ts Outdated
Comment on lines +43 to +45
await act( async () => {
await Promise.resolve();
} );

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing here about potentially changing.

@bcotrim

bcotrim commented Jan 27, 2025

Copy link
Copy Markdown
Contributor Author

Thanks, @katinthehatsite and @fredrikekelund for the review!
I can also see that issue and agree it looks a bit strange.
The delay is indeed a limitation of the current implementation. It's caused by the IPC communication chain - when full-screen changes, it has to go through main process → IPC → renderer process → React state updates.
I tried to find alternative ways to get the full-screen state, like DOM events, but with no success.

I've addressed the other comments, if you both agree, I would propose we merge like this and accept this as a limitation for now.

@fredrikekelund

Copy link
Copy Markdown
Contributor

I say :shipit:

@bcotrim
bcotrim merged commit 65ac7cc into trunk Jan 27, 2025
@bcotrim
bcotrim deleted the fix/sidebar_toggle_large_screens branch January 27, 2025 09:50
bgrgicak pushed a commit that referenced this pull request Jan 29, 2025
* add use-fullscreen hook and adjust topbar icons when fullscreen on mac

* add unit tests

* reduce delay and improve unit tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants