Skip to content

Commit b0f8451

Browse files
committed
actually fix all grids
1 parent 3309092 commit b0f8451

4 files changed

Lines changed: 23 additions & 1 deletion

File tree

src/categories/components/CategoryListDatagrid/CategoryListDatagrid.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export const CategoryListDatagrid = ({
3939
selectionActionButton = null,
4040
hasRowHover = true,
4141
}: CategoryListDatagridProps) => {
42+
const navigate = useNavigator();
4243
const location = useLocation();
4344
const datagridState = useDatagridChangeState();
4445
const intl = useIntl();
@@ -107,6 +108,9 @@ export const CategoryListDatagrid = ({
107108
/>
108109
)}
109110
navigatorOpts={{ state: getPrevLocationState(location) }}
111+
onRowClick={item => {
112+
navigate(handleRowAnchor(item));
113+
}}
110114
/>
111115

112116
<Box paddingX={6}>

src/components/Datagrid/Datagrid.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,17 @@ export const Datagrid: React.FC<DatagridProps> = ({
259259
return;
260260
}
261261

262-
if (onRowClick) {
262+
const intentToOpenInNewTab = args.metaKey || args.ctrlKey;
263+
264+
/**
265+
* Assume rowClick is standard click, if ctrl/cmd is used, let it pass to anchor logic and allow to open in a new tab
266+
*
267+
* TODO: This can be refactored, but every Datagrid is used a little different way
268+
*/
269+
if (onRowClick && !intentToOpenInNewTab) {
263270
onRowClick(item);
271+
272+
return;
264273
}
265274

266275
if (getCellAction(availableColumns, item[0])) {
@@ -278,6 +287,7 @@ export const Datagrid: React.FC<DatagridProps> = ({
278287
metaKey: args.metaKey,
279288
ctrlKey: args.ctrlKey,
280289
shiftKey: args.shiftKey,
290+
bubbles: true,
281291
});
282292

283293
rowAnchorRef.current.dispatchEvent(clickEvent);

src/orders/views/OrderDraftList/OrderDraftList.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,10 @@ export const OrderDraftList: React.FC<OrderDraftListProps> = ({ params }) => {
170170
return (
171171
<PaginatorContext.Provider value={paginationValues}>
172172
<OrderDraftListPage
173+
// @ts-expect-error - due to strict-ignores, this prop is not typed properly but it is passed.
174+
onRowClick={item => {
175+
navigate(orderUrl(item));
176+
}}
173177
selectedFilterPreset={selectedPreset}
174178
filterOpts={getFilterOpts(params)}
175179
limits={limitOpts.data?.shop.limits}

src/orders/views/OrderList/OrderList.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,10 @@ export const OrderList: React.FC<OrderListProps> = ({ params }) => {
132132
return (
133133
<PaginatorContext.Provider value={paginationValues}>
134134
<OrderListPage
135+
// @ts-expect-error - due to strict-ignores, this prop is not typed properly but it is passed.
136+
onRowClick={item => {
137+
navigate(orderUrl(item));
138+
}}
135139
settings={settings}
136140
currentTab={selectedPreset}
137141
disabled={!data}

0 commit comments

Comments
 (0)