Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[data grid] A form field element should have an id or name attribute #15112

Closed
Vagizova opened this issue Oct 25, 2024 · 5 comments · Fixed by #15178
Closed

[data grid] A form field element should have an id or name attribute #15112

Vagizova opened this issue Oct 25, 2024 · 5 comments · Fixed by #15178
Labels
bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module! feature: Selection Related to the data grid Selection feature good first issue Great for first contributions. Enable to learn the contribution process.

Comments

@Vagizova
Copy link

Vagizova commented Oct 25, 2024

Steps to reproduce

Link to live example: example

Steps:

  1. open console
  2. you can see, there is a bunch of issues about checkboxes in selection columns

Current behavior

Inputs do not have name or id attr, so i have hundreds issues in my console. It is annoying

Expected behavior

No response

Context

No response

Your environment

npx @mui/envinfo
  Don't forget to mention which browser you used.
  Output from `npx @mui/envinfo` goes here.

Search keywords: row selection checkboxes

@Vagizova Vagizova added bug 🐛 Something doesn't work status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Oct 25, 2024
@github-actions github-actions bot added the component: data grid This is the name of the generic UI component, not the React module! label Oct 25, 2024
@KenanYusuf KenanYusuf changed the title [datagrid] A form field element should have an id or name attribute [data grid] A form field element should have an id or name attribute Oct 25, 2024
@michelengelen
Copy link
Member

Hey @Vagizova ... I cannot reproduce the issue you are facing. The only two errors I can see are those about the resizeObserver and the strictMode (a CSB bug apparently)

Locally it does not even show a single one of those

Could you elaborate on the issue you are facing a bit or share screen recordings and screenshots?

@michelengelen michelengelen added status: waiting for author Issue with insufficient information feature: Selection Related to the data grid Selection feature and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Oct 28, 2024
@Vagizova
Copy link
Author

@michelengelen Hey, sure! Here it is: https://codesandbox.io/embed/kyppc4?module=/src/Demo.tsx&fontsize=12

screen-recording-2024-10-28-at-223851_avd4fAgA.mp4

@github-actions github-actions bot added status: waiting for maintainer These issues haven't been looked at yet by a maintainer and removed status: waiting for author Issue with insufficient information labels Oct 28, 2024
@michelengelen
Copy link
Member

Thanks @Vagizova ... adding a name or id should be very straightforward ... let me check real quick.

@michelengelen
Copy link
Member

OK< so a fix for that should be fairly easy:

diff --git a/packages/x-data-grid/src/components/columnSelection/GridCellCheckboxRenderer.tsx b/packages/x-data-grid/src/components/columnSelection/GridCellCheckboxRenderer.tsx
index 5bfadd9b9..6ff8fcf96 100644
--- a/packages/x-data-grid/src/components/columnSelection/GridCellCheckboxRenderer.tsx
+++ b/packages/x-data-grid/src/components/columnSelection/GridCellCheckboxRenderer.tsx
@@ -107,6 +107,8 @@ const GridCellCheckboxForwardRef = React.forwardRef<HTMLInputElement, GridRender
         ? isChecked && !isIndeterminate
         : isChecked;

+    const checkBoxId = `checkbox_${id}`;
+
     return (
       <rootProps.slots.baseCheckbox
         ref={handleRef}
@@ -119,6 +121,7 @@ const GridCellCheckboxForwardRef = React.forwardRef<HTMLInputElement, GridRender
         indeterminate={isIndeterminate}
         disabled={!isSelectable}
         touchRippleRef={rippleRef as any /* FIXME: typing error */}
+        id={checkBoxId}
         {...rootProps.slotProps?.baseCheckbox}
         {...other}
       />
diff --git a/packages/x-data-grid/src/components/columnSelection/GridHeaderCheckbox.tsx b/packages/x-data-grid/src/components/columnSelection/GridHeaderCheckbox.tsx
index f968f9108..e01280f54 100644
--- a/packages/x-data-grid/src/components/columnSelection/GridHeaderCheckbox.tsx
+++ b/packages/x-data-grid/src/components/columnSelection/GridHeaderCheckbox.tsx
@@ -145,6 +145,7 @@ const GridHeaderCheckbox = React.forwardRef<HTMLButtonElement, GridColumnHeaderP
         tabIndex={tabIndex}
         onKeyDown={handleKeyDown}
         disabled={!isMultipleRowSelectionEnabled(rootProps)}
+        id={'checkbox_header'}
         {...rootProps.slotProps?.baseCheckbox}
         {...other}
       />

I'll open this up as a good first issue.

@michelengelen michelengelen added good first issue Great for first contributions. Enable to learn the contribution process. and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Oct 29, 2024
Copy link

This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue.
Now, if you have additional information related to this issue or things that could help future readers, feel free to leave a comment.

Note

@Vagizova How did we do? Your experience with our support team matters to us. If you have a moment, please share your thoughts in this short Support Satisfaction survey.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module! feature: Selection Related to the data grid Selection feature good first issue Great for first contributions. Enable to learn the contribution process.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants