Skip to content

Commit

Permalink
Datagrid opens in new tab when click with cmd button (#5378)
Browse files Browse the repository at this point in the history
* Datagrid opens in new tab when click with cmd button

* Add changeset

* Shorten code
  • Loading branch information
poulch authored Jan 29, 2025
1 parent 6e46436 commit 8032935
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/new-monkeys-talk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"saleor-dashboard": patch
---

You can now open datagrid list item in new tab using cmd/ctrl button
8 changes: 7 additions & 1 deletion src/components/Datagrid/Datagrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,13 @@ export const Datagrid: React.FC<DatagridProps> = ({
e.preventDefault();

if (e.currentTarget.dataset.reactRouterPath) {
navigate(e.currentTarget.dataset.reactRouterPath, navigatorOpts);
const url = e.currentTarget.dataset.reactRouterPath;

if (e.metaKey || e.ctrlKey) {
window.open(url, "_blank");
} else {
navigate(url, navigatorOpts);
}
}
}}
/>
Expand Down

0 comments on commit 8032935

Please sign in to comment.