fix(sidebar): cache tooltip overflow measurement

This commit is contained in:
t8y2 committed 2026-07-02 11:35:37 +08:00
1 parent de7f2fe6b6
commit 6ee535de34
3 files changed
+80 -3

No files matched your search

@@ -0,0 +1,11 @@
import { describe, expect, it } from "vitest";
import { shouldMeasureSidebarLabelOverflow } from "@/lib/sidebarLabelTooltip";
describe("shouldMeasureSidebarLabelOverflow", () => {
it("measures only plain truncated-label tooltip candidates", () => {
expect(shouldMeasureSidebarLabelOverflow({ hasDetailTooltip: false, isRenaming: false, usesFullWidthLabel: false })).toBe(true);
expect(shouldMeasureSidebarLabelOverflow({ hasDetailTooltip: true, isRenaming: false, usesFullWidthLabel: false })).toBe(false);
expect(shouldMeasureSidebarLabelOverflow({ hasDetailTooltip: false, isRenaming: true, usesFullWidthLabel: false })).toBe(false);
expect(shouldMeasureSidebarLabelOverflow({ hasDetailTooltip: false, isRenaming: false, usesFullWidthLabel: true })).toBe(false);
});
});
@@ -0,0 +1,3 @@
export function shouldMeasureSidebarLabelOverflow(options: { hasDetailTooltip: boolean; isRenaming: boolean; usesFullWidthLabel: boolean }): boolean {
return !options.isRenaming && !options.hasDetailTooltip && !options.usesFullWidthLabel;
}