fix(web): single grid row spacing (#30277)

This commit is contained in:
Jason Rasmussen
2026-07-27 14:13:11 +00:00
committed by GitHub
parent e3385ce183
commit bc6bf388c0
@@ -10,16 +10,11 @@
let container: HTMLElement | undefined = $state();
let contentRect: DOMRectReadOnly | undefined = $state();
const getGridGap = (element: Element) => {
const getColumnGap = (element: Element) => {
const style = getComputedStyle(element);
return {
columnGap: parsePixels(style.columnGap),
};
return Number.parseInt(style.columnGap) || 0;
};
const parsePixels = (style: string) => Math.trunc(Number(style)) || 0;
const getItemCount = (container: HTMLElement, containerWidth: number) => {
if (!container.firstElementChild) {
return 1;
@@ -27,7 +22,7 @@
const childContentRect = container.firstElementChild.getBoundingClientRect();
const childWidth = Math.floor(childContentRect.width || Infinity);
const { columnGap } = getGridGap(container);
const columnGap = getColumnGap(container);
return Math.floor((containerWidth + columnGap) / (childWidth + columnGap)) || 1;
};