mirror of
https://github.com/bulwarkmail/webmail.git
synced 2026-11-06 00:15:32 +00:00
fix: stop a sliver of next Monday showing at the edge of the week view
This commit is contained in:
@@ -186,3 +186,20 @@ describe('CalendarWeekView all-day and tasks height cap', () => {
|
||||
expect(screen.getByRole('button', { name: /events.show_more|events.show_less/ })).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
describe('CalendarWeekView column width', () => {
|
||||
afterEach(() => {
|
||||
cleanup();
|
||||
vi.restoreAllMocks();
|
||||
});
|
||||
|
||||
// Rounded down, the columns left a few pixels at the edge, where next Monday showed through.
|
||||
it('fills the pane with exactly seven columns when the width does not divide evenly', () => {
|
||||
vi.spyOn(HTMLElement.prototype, 'clientWidth', 'get').mockReturnValue(1000);
|
||||
renderView();
|
||||
const columns = document.querySelector<HTMLElement>('[style*="grid-template-columns"]')!;
|
||||
const colWidth = parseFloat(/([\d.]+)px/.exec(columns.style.gridTemplateColumns)![1]);
|
||||
// 1000px less the 56px hour gutter
|
||||
expect(colWidth * 7).toBeCloseTo(944, 1);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -152,7 +152,8 @@ export function CalendarWeekView({
|
||||
|
||||
const measureColWidth = useCallback((root: HTMLElement | null) => {
|
||||
if (isMobile || !root) return MOBILE_COL_WIDTH;
|
||||
return Math.max(MIN_COL_WIDTH, Math.floor((root.clientWidth - gutterWidth) / columnsPerWeek));
|
||||
// Not rounded down: the pixels left over showed a sliver of next Monday at the edge.
|
||||
return Math.max(MIN_COL_WIDTH, (root.clientWidth - gutterWidth) / columnsPerWeek);
|
||||
}, [isMobile, gutterWidth, columnsPerWeek]);
|
||||
const [colWidth, setColWidth] = useState(MOBILE_COL_WIDTH);
|
||||
const [viewportWidth, setViewportWidth] = useState(0);
|
||||
|
||||
Reference in New Issue
Block a user