Skip to content

Commit e203e05

Browse files
authored
Merge pull request #8425 from sagemathinc/fix-activitybar-compact-8421
frontend/activity bar: improve condensed layout calculation
2 parents 6d0331d + d5823ed commit e203e05

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/packages/frontend/project/page/activity-bar-tabs.tsx

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ import { tab_to_path } from "@cocalc/util/misc";
2424
import { COLORS } from "@cocalc/util/theme";
2525
import { getValidActivityBarOption } from "./activity-bar";
2626
import {
27-
TOGGLE_ACTIVITY_BAR_TOGGLE_BUTTON_SPACE,
2827
ACTIVITY_BAR_EXPLANATION,
2928
ACTIVITY_BAR_KEY,
3029
ACTIVITY_BAR_LABELS,
3130
ACTIVITY_BAR_OPTIONS,
3231
ACTIVITY_BAR_TOGGLE_LABELS,
32+
TOGGLE_ACTIVITY_BAR_TOGGLE_BUTTON_SPACE,
3333
} from "./activity-bar-consts";
3434
import { FileTab, FIXED_PROJECT_TABS, FixedTab } from "./file-tab";
3535
import FileTabs from "./file-tabs";
@@ -94,9 +94,10 @@ interface FVTProps {
9494
setHomePageButtonWidth: (width: number) => void;
9595
}
9696

97-
export function VerticalFixedTabs(props: Readonly<FVTProps>) {
97+
export function VerticalFixedTabs({
98+
setHomePageButtonWidth,
99+
}: Readonly<FVTProps>) {
98100
const intl = useIntl();
99-
const { setHomePageButtonWidth } = props;
100101
const {
101102
actions,
102103
project_id,
@@ -122,6 +123,7 @@ export function VerticalFixedTabs(props: Readonly<FVTProps>) {
122123

123124
const gh = gap.current.clientHeight;
124125
const ph = parent.current.clientHeight;
126+
if (ph == 0) return;
125127

126128
if (refCondensed.current) {
127129
// 5px slack to avoid flickering
@@ -133,7 +135,6 @@ export function VerticalFixedTabs(props: Readonly<FVTProps>) {
133135
if (gh < 1) {
134136
setCondensed(true);
135137
refCondensed.current = true;
136-
// max? because when we start with a thin window, the ph is already smaller than th
137138
breakPoint.current = ph;
138139
}
139140
}
@@ -151,6 +152,10 @@ export function VerticalFixedTabs(props: Readonly<FVTProps>) {
151152
};
152153
}, []);
153154

155+
useEffect(() => {
156+
calcCondensed();
157+
}, [showActBarLabels, parent.current, gap.current]);
158+
154159
useEffect(() => {
155160
if (parent.current == null) return;
156161

@@ -171,7 +176,7 @@ export function VerticalFixedTabs(props: Readonly<FVTProps>) {
171176
return () => {
172177
observer.disconnect();
173178
};
174-
}, [condensed, parent.current]);
179+
}, [condensed, showActBarLabels, parent.current, gap.current]);
175180

176181
const items: ReactNode[] = [];
177182
for (const nameStr in FIXED_PROJECT_TABS) {
@@ -269,7 +274,7 @@ export function VerticalFixedTabs(props: Readonly<FVTProps>) {
269274
>
270275
{items}
271276
{/* moves the layout selector to the bottom */}
272-
<div ref={gap} style={{ flex: 1 }}></div>{" "}
277+
<div ref={gap} style={{ flex: 1 }}></div>
273278
{/* moves hide switch to the bottom */}
274279
<LayoutSelector actBar={actBar} />
275280
{renderToggleActivityBar()}

0 commit comments

Comments
 (0)