Skip to content

Commit c7515ff

Browse files
committed
fix: merge DataGrid layout + add min width to sessions location column
1 parent a1c73fc commit c7515ff

3 files changed

Lines changed: 9 additions & 75 deletions

File tree

src/app/(main)/websites/[websiteId]/sessions/SessionsTable.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export function SessionsTable({
2525
<DataColumn id="visits" label={t(labels.visits)} width="80px" />
2626
<DataColumn id="views" label={t(labels.views)} width="80px" />
2727
<DataColumn id="events" label={t(labels.events)} width="80px" />
28-
<DataColumn id="location" label={t(labels.location)}>
28+
<DataColumn id="location" label={t(labels.location)} width="200px">
2929
{(row: any) => (
3030
<TypeIcon type="country" value={row.country}>
3131
{row.city ? `${row.city}, ` : ''}

src/components/charts/Chart.tsx

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -122,17 +122,6 @@ export function Chart({
122122
return (
123123
<Column gap="6">
124124
<Box {...props}>
125-
{/*
126-
Position the canvas absolutely inside a relative-positioned
127-
wrapper. Chart.js writes inline pixel sizes onto the canvas, and
128-
while it lives in the normal flow that pixel width propagates up
129-
as min/max-content through every flex parent into the surrounding
130-
CSS Grid track, pinning the chart's column at its widest measured
131-
size and only resetting on a full page reload. Taking the canvas
132-
out of flow with position: absolute breaks that propagation; the
133-
wrapper sizes purely from its parent (width: 100%, height: 100%)
134-
and Chart.js' ResizeObserver picks up viewport changes.
135-
*/}
136125
<div style={{ position: 'relative', width: '100%', height: '100%', overflow: 'hidden' }}>
137126
<canvas ref={canvas} style={{ position: 'absolute', top: 0, left: 0 }} />
138127
</div>

src/components/common/DataGrid.tsx

Lines changed: 8 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -62,67 +62,6 @@ export function DataGrid({
6262
const child = data ? (typeof children === 'function' ? children(data) : children) : null;
6363

6464
return (
65-
<Column gap="4" minHeight="300px">
66-
{allowSearch && (
67-
<Row alignItems="center" justifyContent="space-between" wrap="wrap" gap>
68-
<SearchField
69-
value={search}
70-
onSearch={handleSearch}
71-
delay={searchDelay || DEFAULT_SEARCH_DELAY}
72-
autoFocus={autoFocus}
73-
placeholder={t(labels.search)}
74-
/>
75-
{renderActions?.()}
76-
</Row>
77-
)}
78-
<LoadingPanel
79-
data={data?.data}
80-
isLoading={isLoading}
81-
isFetching={isFetching}
82-
error={error}
83-
renderEmpty={renderEmpty}
84-
>
85-
{data && (
86-
<>
87-
{/*
88-
Wrap the table in a horizontally scrollable container. The
89-
react-zen DataTable lays its columns out on a CSS Grid with
90-
fixed pixel widths, so the sum of column widths becomes the
91-
table's max-content and propagates up through the surrounding
92-
flex chain into the Tabs grid track, pinning every ancestor
93-
wider than the viewport on small screens. overflow-x: auto on
94-
its own does not break that chain because the wrapper still
95-
stretches to its parent's width. Setting display: grid with
96-
grid-template-columns: minmax(0, 1fr) gives the wrapper an
97-
explicit 1fr column that resolves to the available space,
98-
caps its own intrinsic width, and lets overflow-x: auto
99-
kick in so the user can scroll the columns horizontally
100-
instead of having the card overflow off screen.
101-
*/}
102-
<div
103-
style={{
104-
display: 'grid',
105-
gridTemplateColumns: 'minmax(0, 1fr)',
106-
overflowX: 'auto',
107-
}}
108-
>
109-
{isValidElement(child)
110-
? cloneElement(child as ReactElement<any>, { displayMode })
111-
: child}
112-
</div>
113-
{showPager && (
114-
<Row marginTop="6">
115-
<Pager
116-
page={data.page}
117-
pageSize={data.pageSize}
118-
count={data.count}
119-
onPageChange={handlePageChange}
120-
/>
121-
</Row>
122-
)}
123-
</>
124-
)}
125-
</LoadingPanel>
12665
<Column gap="4" minHeight="300px" justifyContent="space-between">
12766
<Column gap="4">
12867
{allowSearch && (
@@ -145,11 +84,17 @@ export function DataGrid({
14584
renderEmpty={renderEmpty}
14685
>
14786
{data && (
148-
<Column>
87+
<div
88+
style={{
89+
display: 'grid',
90+
gridTemplateColumns: 'minmax(0, 1fr)',
91+
overflowX: 'auto',
92+
}}
93+
>
14994
{isValidElement(child)
15095
? cloneElement(child as ReactElement<any>, { displayMode })
15196
: child}
152-
</Column>
97+
</div>
15398
)}
15499
</LoadingPanel>
155100
</Column>

0 commit comments

Comments
 (0)