Skip to content

Commit e04ad99

Browse files
rritik772Ritik Ranjan
authored and
Ritik Ranjan
committed
feature/auto-hide-tab-bar refactored code and updated doc
1 parent de587c7 commit e04ad99

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

Diff for: docs/docs/config.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ wsh editconfig
6868
| window:magnifiedblockblursecondarypx | int | change the blur in CSS pixels that is applied to the visible portions of non-magnified blocks when a block is magnified (see [backdrop-filter](https://developer.mozilla.org/en-US/docs/Web/CSS/backdrop-filter) for more info on how this gets applied) |
6969
| window:maxtabcachesize | int | number of tabs to cache. when tabs are cached, switching between them is very fast. (defaults to 10) |
7070
| window:showmenubar | bool | set to use the OS-native menu bar (Windows and Linux only, requires app restart) |
71-
| window:autohidetabsbar | bool | auto hide tab bar based on true or false
71+
| window:autohidetabsbar | bool | auto hide tab bar based on true or false (requires restart)
7272
| window:nativetitlebar | bool | set to use the OS-native title bar, rather than the overlay (Windows and Linux only, requires app restart) |
7373
| window:disablehardwareacceleration | bool | set to disable Chromium hardware acceleration to resolve graphical bugs (requires app restart) |
7474
| telemetry:enabled | bool | set to enable/disable telemetry |

Diff for: frontend/app/tab/tabbar.tsx

+6-4
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ const TabBar = memo(({ workspace }: TabBarProps) => {
174174
const isFullScreen = useAtomValue(atoms.isFullScreen);
175175

176176
const settings = useAtomValue(atoms.settingsAtom);
177-
const autoHideTabsBar = useRef<boolean>(settings["window:autohidetabsbar"]);
177+
const autoHideTabsBar = settings?.["window:autohidetabsbar"] ?? false;
178178

179179
let prevDelta: number;
180180
let prevDragDirection: string;
@@ -185,13 +185,15 @@ const TabBar = memo(({ workspace }: TabBarProps) => {
185185
const tabBarHeight = tabBar.clientHeight + 1;
186186

187187
if (currentY < 10) tabBar.style.top = '0px';
188-
if (autoHideTabsBar.current && currentY > tabBarHeight) tabBar.style.top = `-${tabBarHeight}px`;
188+
if (autoHideTabsBar && currentY > tabBarHeight) tabBar.style.top = `-${tabBarHeight}px`;
189189
};
190190

191191
useEffect(() => {
192+
if (!autoHideTabsBar) return;
193+
192194
document.addEventListener("mousemove", handleAutoHideTabsBar);
193195
return () => document.removeEventListener("mousemove", handleAutoHideTabsBar);
194-
}, [])
196+
}, [autoHideTabsBar])
195197

196198
// Update refs when tabIds change
197199
useEffect(() => {
@@ -669,7 +671,7 @@ const TabBar = memo(({ workspace }: TabBarProps) => {
669671
title: "Add Tab",
670672
};
671673
return (
672-
<div ref={tabbarWrapperRef} className={`tab-bar-wrapper${autoHideTabsBar.current ? '-auto-hide' : ''}`}>
674+
<div ref={tabbarWrapperRef} className={`tab-bar-wrapper${autoHideTabsBar ? '-auto-hide' : ''}`}>
673675
<WindowDrag ref={draggerLeftRef} className="left" />
674676
{appMenuButton}
675677
{devLabel}

0 commit comments

Comments
 (0)