adazzle / react-data-grid

Feature-rich and customizable data grid React component
https://adazzle.github.io/react-data-grid/
Other
6.93k stars 2.18k forks source link

Add prop id to react-data-grid #3305

Open jolierabideau opened 1 year ago

jolierabideau commented 1 year ago

Hi! ๐Ÿ‘‹

Firstly, thanks for your work on this project! ๐Ÿ™‚

Today I used patch-package to patch react-data-grid@7.0.0-beta.34 for the project I'm working on. I added an id prop.

Here is the diff that solved my problem:

diff --git a/node_modules/react-data-grid/lib/bundle.cjs b/node_modules/react-data-grid/lib/bundle.cjs
index 5ae3bcb..a64c97a 100644
--- a/node_modules/react-data-grid/lib/bundle.cjs
+++ b/node_modules/react-data-grid/lib/bundle.cjs
@@ -1927,7 +1927,8 @@ function DataGrid(props, ref) {
     'aria-label': ariaLabel,
     'aria-labelledby': ariaLabelledBy,
     'aria-describedby': ariaDescribedBy,
-    'data-testid': testId
+    'data-testid': testId,
+    id: id
   } = props;
   const defaultRenderers = useDefaultRenderers();
   const rowHeight = rawRowHeight ?? 35;
@@ -2723,6 +2724,7 @@ function DataGrid(props, ref) {
     onScroll: handleScroll,
     onKeyDown: handleKeyDown,
     "data-testid": testId,
+    id: id,
     children: [hasGroups && /*#__PURE__*/jsxRuntime.jsx("div", {
       ref: rowRef,
       tabIndex: isGroupRowFocused ? 0 : -1,
diff --git a/node_modules/react-data-grid/lib/bundle.js b/node_modules/react-data-grid/lib/bundle.js
index 88540dd..1480bcd 100644
--- a/node_modules/react-data-grid/lib/bundle.js
+++ b/node_modules/react-data-grid/lib/bundle.js
@@ -1923,7 +1923,8 @@ function DataGrid(props, ref) {
     'aria-label': ariaLabel,
     'aria-labelledby': ariaLabelledBy,
     'aria-describedby': ariaDescribedBy,
-    'data-testid': testId
+    'data-testid': testId,
+    id: id,
   } = props;
   const defaultRenderers = useDefaultRenderers();
   const rowHeight = rawRowHeight ?? 35;
@@ -2719,6 +2720,7 @@ function DataGrid(props, ref) {
     onScroll: handleScroll,
     onKeyDown: handleKeyDown,
     "data-testid": testId,
+    id: id,
     children: [hasGroups && /*#__PURE__*/jsx("div", {
       ref: rowRef,
       tabIndex: isGroupRowFocused ? 0 : -1,
diff --git a/node_modules/react-data-grid/lib/index.d.ts b/node_modules/react-data-grid/lib/index.d.ts
index d6ac112..2ca3db5 100644
--- a/node_modules/react-data-grid/lib/index.d.ts
+++ b/node_modules/react-data-grid/lib/index.d.ts
@@ -203,6 +203,7 @@ export declare interface DataGridProps<R, SR = unknown, K extends Key = Key> ext
     /** @default 'ltr' */
     direction?: Maybe<Direction>;
     'data-testid'?: Maybe<string>;
+    id?: Maybe<string>;
 }

 declare const _default: <R, SR = unknown, K extends Key = Key>(props: DataGridProps<R, SR, K> & RefAttributes<DataGridHandle>) => JSX.Element;

This issue body was partially generated by patch-package.

abenhamdine commented 1 year ago

Here is the diff that solved my problem:

Hi, you should describe your pb first before posting a patch, why do you need to add prop id ?