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] MUI: useResizeContainer - The parent DOM element of the data grid has an empty width. #7215

Closed
2 tasks done
Mattc1221 opened this issue Dec 15, 2022 · 6 comments
Closed
2 tasks done
Labels
component: data grid This is the name of the generic UI component, not the React module! status: waiting for author Issue with insufficient information support: commercial Support request from paid users

Comments

@Mattc1221
Copy link

Order ID 💳

51377

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

The problem in depth 🔍

In our application, our DataGridPro component works well but I am getting the following error for every DataGrid component when I empty cache and hard reload the page:
Screen Shot 2022-12-15 at 11 29 05 AM

If I'm understanding correctly, the issue is that the container around DataGrid needs some set size as the DataGrid component expands to fill that size. In my case, we have a vertical scrollable container with many DataGrid components inside. The width for each DataGrid component is based on its content. Following this #1241 (comment) comment to implement dynamic column widths. We calculate the width of each column based on content length (max of 500px), sum all column widths together and then set the width property of the container around the DataGrid component to that summed width. We also have a table header that has a dynamic min width and we want the DataGrids min width to be bound by that as well

Note, I have also tried inserting the example code from your doc's site (here) into the project and the issue was still present.

This is also a very tricky issue to reproduce in a sandbox. I will keep trying to create a repro, but for now, I'll add the DOM tree.

DOM tree
<div class="ChartContainer fit-content false" id="chartContainer-2">
   <div class="ChartHeader false false" style="opacity: 1; transition: opacity 0.5s ease 0s;">
      <span class="MuiButtonBase-root MuiCheckbox-root MuiCheckbox-colorPrimary PrivateSwitchBase-root MuiCheckbox-root MuiCheckbox-colorPrimary grey-out css-1rvn7sh-MuiButtonBase-root-MuiCheckbox-root">
         <input class="PrivateSwitchBase-input css-1m9pwf3" type="checkbox" data-indeterminate="false">
         <svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium css-i4bv87-MuiSvgIcon-root" focusable="false" aria-hidden="true" viewBox="0 0 24 24" data-testid="CheckBoxOutlineBlankIcon">
            <path d="M19 5v14H5V5h14m0-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2z"></path>
         </svg>
         <span class="MuiTouchRipple-root css-8je8zh-MuiTouchRipple-root">
         </span>
      </span>
      <div class="ChartHeader-Button" aria-label="Minimize table" data-mui-internal-clone-element="true" style="cursor: pointer;">
         <svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 16 16" color="grey" height="16" width="16" xmlns="http://www.w3.org/2000/svg" style="color: grey;">
            <path d="M14 8v1H3V8h11z"></path>
         </svg>
      </div>
      <span class="ChartHeader-Info" title="Table1">
         <span class="ChartHeader-Title">
            <div aria-label="Double-click to edit" class="" data-mui-internal-clone-element="true">
               <div align="left">
                  <div disabled="" spellcheck="false" contenteditable="false">
                     sheet1
                  </div>
               </div>
            </div>
         </span>
         <span class="ChartHeader-Version">
         v1</span>
         <div class="ChartHeader-RowInfo">
            ·&nbsp;&nbsp;
            <div class="ChartHeader-ShownRows">
               <div style="display: flex;">
                  Showing 
                  <div style="width: 4.15ch; margin-left: 0.5ch; margin-right: 0.4ch; align-items: center; opacity: 1;">
                     <input type="text" step="10" min="5" readonly="" value="2">
                  </div>
                  of 2 rows
               </div>
            </div>
         </div>
      </span>
      <span class="ChartHeader-ButtonsAndRefreshInfo">
         <div class="ChartHeader-Button" aria-label="Publish" data-mui-internal-clone-element="true">
            <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
               <path d="M12 3v18M3 12h18"></path>
            </svg>
         </div>
         <div class="ChartHeader-Button" aria-label="Export table" data-mui-internal-clone-element="true">
            <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-download exportIcon">
               <path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M7 10l5 5 5-5M12 15V3"></path>
            </svg>
         </div>
         <div class="ChartHeader-Button" aria-label="Add caption" data-mui-internal-clone-element="true">
            <svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 24 24" height="16" width="16" xmlns="http://www.w3.org/2000/svg">
               <path d="M5 8L7 8 7 6 10.252 6 7.68 18 5 18 5 20 13 20 13 18 10.748 18 13.32 6 17 6 17 8 19 8 19 4 5 4z"></path>
            </svg>
         </div>
         <div class="ChartHeader-Button" aria-label="Use this dataset" data-mui-internal-clone-element="true">
            <svg height="16" width="16" fill="currentColor" stroke="currentColor" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 26.458 26.458">
               <g transform="translate(-2.536 -261.903)" stroke="none">
                  <path d="M14.338 263.225v8.64a3.739 3.739 0 0 1 1.427-.287c.49 0 .974.097 1.426.284v-8.637z" style="color: currentcolor; font: 400 medium sans-serif; font-feature-settings: normal; text-indent: 0px; text-align: start; text-decoration: none solid currentcolor; letter-spacing: normal; word-spacing: normal; text-transform: none; writing-mode: lr-tb; direction: ltr; text-orientation: mixed; dominant-baseline: auto; baseline-shift: baseline; text-anchor: start; white-space: normal; clip-rule: nonzero; display: inline; overflow: visible; visibility: visible; opacity: 1; isolation: auto; mix-blend-mode: normal; color-interpolation: srgb; color-interpolation-filters: linearrgb; vector-effect: none; fill: currentcolor; fill-opacity: 1; fill-rule: nonzero; stroke: none; stroke-width: 24.9525; stroke-linecap: round; stroke-linejoin: round; stroke-miterlimit: 4; stroke-dasharray: none; stroke-dashoffset: 0; stroke-opacity: 1; color-rendering: auto; image-rendering: auto; shape-rendering: auto; text-rendering: auto;"></path>
                  <path d="m12.611 273.316-8.039 4.52a1.427 1.427 0 0 0-.522 1.95l4.017 6.501c.941 1.684 3.46.23 2.471-1.426l-2.68-4.643 5.368-2.162a3.739 3.739 0 0 1-1.2-2.74 3.738 3.738 0 0 1 .585-2zM18.924 273.32c.378.597.58 1.29.58 1.997a3.739 3.739 0 0 1-1.2 2.74l5.368 2.16-2.68 4.644c-.992 1.658 1.53 3.114 2.47 1.426l4.018-6.502a1.427 1.427 0 0 0-.523-1.949z" style="color: currentcolor; font: 400 medium sans-serif; font-feature-settings: normal; text-indent: 0px; text-align: start; text-decoration: none solid currentcolor; letter-spacing: normal; word-spacing: normal; text-transform: none; writing-mode: lr-tb; direction: ltr; text-orientation: mixed; dominant-baseline: auto; baseline-shift: baseline; text-anchor: start; white-space: normal; clip-rule: nonzero; display: inline; overflow: visible; visibility: visible; opacity: 1; isolation: auto; mix-blend-mode: normal; color-interpolation: srgb; color-interpolation-filters: linearrgb; vector-effect: none; fill: currentcolor; fill-opacity: 1; fill-rule: nonzero; stroke: none; stroke-width: 24.9525; stroke-linecap: round; stroke-linejoin: round; stroke-miterlimit: 4; stroke-dasharray: none; stroke-dashoffset: 0; stroke-opacity: 1; color-rendering: auto; image-rendering: auto; shape-rendering: auto; text-rendering: auto;"></path>
                  <circle cx="15.765" cy="275.317" r="2.774" style="opacity: 1; vector-effect: none; fill: currentcolor; fill-opacity: 1; stroke: none; stroke-width: 17.7083; stroke-linecap: round; stroke-linejoin: round; stroke-miterlimit: 4; stroke-dasharray: none; stroke-dashoffset: 0; stroke-opacity: 1; marker: none;"></circle>
               </g>
            </svg>
         </div>
         <div class="ChartHeader-Button" aria-label="View Workflow" data-mui-internal-clone-element="true">
            <svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium css-xtuuzo-MuiSvgIcon-root" focusable="false" aria-hidden="true" viewBox="0 0 24 24" data-testid="AccountTreeRoundedIcon">
               <path d="M17 11h3c1.11 0 2-.9 2-2V5c0-1.11-.9-2-2-2h-3c-1.11 0-2 .9-2 2v1H9.01V5c0-1.11-.9-2-2-2H4c-1.1 0-2 .9-2 2v4c0 1.11.9 2 2 2h3c1.11 0 2-.9 2-2V8h2v7.01c0 1.65 1.34 2.99 2.99 2.99H15v1c0 1.11.9 2 2 2h3c1.11 0 2-.9 2-2v-4c0-1.11-.9-2-2-2h-3c-1.11 0-2 .9-2 2v1h-1.01c-.54 0-.99-.45-.99-.99V8h2v1c0 1.1.9 2 2 2z"></path>
            </svg>
         </div>
         <div class="ChartHeader-Button" aria-label="View in a larger window" data-mui-internal-clone-element="true">
            <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
               <path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6M15 3h6v6M10 14 21 3"></path>
            </svg>
         </div>
      </span>
   </div>
   <div class="Chart " id="chart-2" data-context-id="2" style="background-color: white;">
      <div class="Table-Container">
         <div class="Table-Resize-Container" style="width: 372px;">
            <div class="MuiDataGrid-root MuiDataGrid-autoHeight MuiDataGrid-root--densityStandard css-mykdg9-MuiDataGrid-root" role="grid" aria-colcount="3" aria-rowcount="3" aria-multiselectable="true">
               <div>
                  <div></div>
               </div>
               <div class="MuiDataGrid-main css-204u17-MuiDataGrid-main">
                  <div class="MuiDataGrid-columnHeaders css-f3jnds-MuiDataGrid-columnHeaders" style="min-height: 40px; max-height: 40px; line-height: 40px;">
                     <div class="MuiDataGrid-columnHeadersInner css-gl260s-MuiDataGrid-columnHeadersInner" role="rowgroup" style="transform: translate3d(0px, 0px, 0px);">
                        <div role="row" aria-rowindex="1" class="css-yrdy0g-MuiDataGrid-columnHeaderRow">
                           <div class="MuiDataGrid-columnHeader MuiDataGrid-columnHeader--alignRight MuiDataGrid-columnHeader--numeric" role="columnheader" tabindex="0" aria-colindex="1" aria-sort="none" data-field="ColumnOne" style="height: 40px; width: 119px; min-width: 119px; max-width: 119px;">
                              <div class="MuiDataGrid-columnHeaderDraggableContainer" draggable="true">
                                 <div class="MuiDataGrid-columnHeaderTitleContainer">
                                    <div class="MuiDataGrid-columnHeaderTitleContainerContent">
                                       <div class="">
                                          ColumnOne
                                       </div>
                                    </div>
                                 </div>
                                 <div class="MuiDataGrid-menuIcon">
                                    <button class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeSmall MuiDataGrid-menuIconButton css-1pe4mpk-MuiButtonBase-root-MuiIconButton-root" tabindex="-1" type="button" aria-label="Menu" title="Menu" aria-haspopup="true" aria-controls="mui-136" id="mui-137">
                                       <svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeSmall css-ptiqhd-MuiSvgIcon-root" focusable="false" aria-hidden="true" viewBox="0 0 24 24" data-testid="TripleDotsVerticalIcon">
                                          <path d="M12 8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"></path>
                                       </svg>
                                       <span class="MuiTouchRipple-root css-8je8zh-MuiTouchRipple-root">
                                       </span>
                                    </button>
                                 </div>
                              </div>
                              <div class="MuiDataGrid-columnSeparator MuiDataGrid-columnSeparator--sideRight" style="min-height: 40px; opacity: 1;">
                                 <svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium MuiDataGrid-iconSeparator css-i4bv87-MuiSvgIcon-root" focusable="false" aria-hidden="true" viewBox="0 0 24 24" data-testid="SeparatorIcon">
                                    <path d="M11 19V5h2v14z"></path>
                                 </svg>
                              </div>
                           </div>
                           <div class="MuiDataGrid-columnHeader MuiDataGrid-columnHeader--alignRight MuiDataGrid-columnHeader--numeric" role="columnheader" tabindex="-1" aria-colindex="2" aria-sort="none" data-field="ColumnTwo" style="height: 40px; width: 121px; min-width: 121px; max-width: 121px;">
                              <div class="MuiDataGrid-columnHeaderDraggableContainer" draggable="true">
                                 <div class="MuiDataGrid-columnHeaderTitleContainer">
                                    <div class="MuiDataGrid-columnHeaderTitleContainerContent">
                                       <div class="">
                                          ColumnTwo
                                       </div>
                                    </div>
                                 </div>
                                 <div class="MuiDataGrid-menuIcon">
                                    <button class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeSmall MuiDataGrid-menuIconButton css-1pe4mpk-MuiButtonBase-root-MuiIconButton-root" tabindex="-1" type="button" aria-label="Menu" title="Menu" aria-haspopup="true" aria-controls="mui-138" id="mui-139">
                                       <svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeSmall css-ptiqhd-MuiSvgIcon-root" focusable="false" aria-hidden="true" viewBox="0 0 24 24" data-testid="TripleDotsVerticalIcon">
                                          <path d="M12 8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"></path>
                                       </svg>
                                       <span class="MuiTouchRipple-root css-8je8zh-MuiTouchRipple-root">
                                       </span>
                                    </button>
                                 </div>
                              </div>
                              <div class="MuiDataGrid-columnSeparator MuiDataGrid-columnSeparator--sideRight" style="min-height: 40px; opacity: 1;">
                                 <svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium MuiDataGrid-iconSeparator css-i4bv87-MuiSvgIcon-root" focusable="false" aria-hidden="true" viewBox="0 0 24 24" data-testid="SeparatorIcon">
                                    <path d="M11 19V5h2v14z"></path>
                                 </svg>
                              </div>
                           </div>
                           <div class="MuiDataGrid-columnHeader MuiDataGrid-columnHeader--alignRight MuiDataGrid-columnHeader--numeric" role="columnheader" tabindex="-1" aria-colindex="3" aria-sort="none" data-field="ColumnThree" style="height: 40px; width: 132px; min-width: 132px; max-width: 132px;">
                              <div class="MuiDataGrid-columnHeaderDraggableContainer" draggable="true">
                                 <div class="MuiDataGrid-columnHeaderTitleContainer">
                                    <div class="MuiDataGrid-columnHeaderTitleContainerContent">
                                       <div class="">
                                          ColumnThree
                                       </div>
                                    </div>
                                 </div>
                                 <div class="MuiDataGrid-menuIcon">
                                    <button class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeSmall MuiDataGrid-menuIconButton css-1pe4mpk-MuiButtonBase-root-MuiIconButton-root" tabindex="-1" type="button" aria-label="Menu" title="Menu" aria-haspopup="true" aria-controls="mui-140" id="mui-141">
                                       <svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeSmall css-ptiqhd-MuiSvgIcon-root" focusable="false" aria-hidden="true" viewBox="0 0 24 24" data-testid="TripleDotsVerticalIcon">
                                          <path d="M12 8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"></path>
                                       </svg>
                                       <span class="MuiTouchRipple-root css-8je8zh-MuiTouchRipple-root">
                                       </span>
                                    </button>
                                 </div>
                              </div>
                              <div class="MuiDataGrid-columnSeparator MuiDataGrid-columnSeparator--sideRight" style="min-height: 40px; opacity: 1;">
                                 <svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium MuiDataGrid-iconSeparator css-i4bv87-MuiSvgIcon-root" focusable="false" aria-hidden="true" viewBox="0 0 24 24" data-testid="SeparatorIcon">
                                    <path d="M11 19V5h2v14z"></path>
                                 </svg>
                              </div>
                           </div>
                        </div>
                     </div>
                  </div>
                  <div style="overflow: visible; width: 0px;">
                     <div class="MuiDataGrid-virtualScroller css-1w5m2wr-MuiDataGrid-virtualScroller" style="width: 462px; height: auto; margin-top: 40px; overflow: hidden;">
                        <div class="MuiDataGrid-virtualScrollerContent css-1kwdphh-MuiDataGrid-virtualScrollerContent" style="width: auto; height: 76.875px; min-height: calc((100% - 0px) - 0px);">
                           <div class="MuiDataGrid-virtualScrollerRenderZone css-s1v7zr-MuiDataGrid-virtualScrollerRenderZone" style="transform: translate3d(0px, 0px, 0px);">
                              <div data-id="0" data-rowindex="0" role="row" class="MuiDataGrid-row MuiDataGrid-row--dynamicHeight" aria-rowindex="2" aria-selected="false" style="max-height: none; min-height: auto;">
                                 <div class="MuiDataGrid-cell--withRenderer MuiDataGrid-cell MuiDataGrid-cell--textRight" role="cell" data-field="ColumnOne" data-colindex="0" aria-colindex="1" aria-colspan="1" tabindex="-1" style="min-width: 119px; max-width: 119px; min-height: auto; max-height: none;">
                                    <span style="overflow: hidden; text-overflow: ellipsis;">
                                    123456</span>
                                 </div>
                                 <div class="MuiDataGrid-cell--withRenderer MuiDataGrid-cell MuiDataGrid-cell--textRight" role="cell" data-field="ColumnTwo" data-colindex="1" aria-colindex="2" aria-colspan="1" tabindex="-1" style="min-width: 121px; max-width: 121px; min-height: auto; max-height: none;">
                                    <span style="overflow: hidden; text-overflow: ellipsis;">
                                    654321</span>
                                 </div>
                                 <div class="MuiDataGrid-cell--withRenderer MuiDataGrid-cell MuiDataGrid-cell--textRight" role="cell" data-field="ColumnThree" data-colindex="2" aria-colindex="3" aria-colspan="1" tabindex="-1" style="min-width: 132px; max-width: 132px; min-height: auto; max-height: none;">
                                    <span style="overflow: hidden; text-overflow: ellipsis;">
                                    1.23</span>
                                 </div>
                                 <div class="MuiDataGrid-cell" style="width: 90px;"></div>
                              </div>
                              <div data-id="1" data-rowindex="1" role="row" class="MuiDataGrid-row MuiDataGrid-row--lastVisible MuiDataGrid-row--dynamicHeight" aria-rowindex="3" aria-selected="false" style="max-height: none; min-height: auto;">
                                 <div class="MuiDataGrid-cell--withRenderer MuiDataGrid-cell MuiDataGrid-cell--textRight" role="cell" data-field="ColumnOne" data-colindex="0" aria-colindex="1" aria-colspan="1" tabindex="-1" style="min-width: 119px; max-width: 119px; min-height: auto; max-height: none;">
                                    <span style="overflow: hidden; text-overflow: ellipsis;">
                                    347234</span>
                                 </div>
                                 <div class="MuiDataGrid-cell--withRenderer MuiDataGrid-cell MuiDataGrid-cell--textRight" role="cell" data-field="ColumnTwo" data-colindex="1" aria-colindex="2" aria-colspan="1" tabindex="-1" style="min-width: 121px; max-width: 121px; min-height: auto; max-height: none;">
                                    <span style="overflow: hidden; text-overflow: ellipsis;">
                                    394858</span>
                                 </div>
                                 <div class="MuiDataGrid-cell--withRenderer MuiDataGrid-cell MuiDataGrid-cell--textRight" role="cell" data-field="ColumnThree" data-colindex="2" aria-colindex="3" aria-colspan="1" tabindex="-1" style="min-width: 132px; max-width: 132px; min-height: auto; max-height: none;">
                                    <span style="overflow: hidden; text-overflow: ellipsis;">
                                    2.35</span>
                                 </div>
                                 <div class="MuiDataGrid-cell" style="width: 90px;"></div>
                              </div>
                           </div>
                        </div>
                     </div>
                  </div>
                  <div class="Mui-resizeTriggers">
                     <div class="expand-trigger">
                        <div style="width: 463px; height: 118px;"></div>
                     </div>
                     <div class="contract-trigger"></div>
                  </div>
               </div>
            </div>
         </div>
      </div>
   </div>
</div>
Table Styling
.Table-Container {
  width: 100%;
  max-width: -webkit-fill-available;
  border: 5px solid white;

  .Table-Resize-Container {
    min-width: -webkit-fill-available;
    max-width: -webkit-fill-available;

    .MuiDataGrid-root {
      border: none;

      .MuiDataGrid-columnHeader {
        padding: 0 8px;

        .MuiDataGrid-columnHeaderTitleContainerContent {
          font-size: 14px;
          color: gray;
        }

        .MuiDataGrid-columnSeparator {
          width: 0;
          visibility: hidden;
        }

        .MuiDataGrid-menuIcon {
          margin-left: -6px !important;
        }
      }

      .MuiDataGrid-row {
        &.odd {
          background: #f5f5f5;
        }

        &:hover {
          background: #f0f0f0;
        }

        .MuiDataGrid-cell {
          font-size: 15px;
          color: #2e2f3e;
        }

        &.expanded {
          min-height: auto !important;
          max-height: none !important;

          .MuiDataGrid-cell {
            min-height: auto !important;
            max-height: none !important;
            overflow: visible;
            text-overflow: unset;
            white-space: break-spaces;

            .link-wrapper,
            span {
              width: 100%;
              overflow: visible !important;
              text-overflow: unset !important;
              overflow-wrap: break-word;
            }
          }
        }
      }

      .MuiDataGrid-footerContainer {
        justify-content: start;
      }
    }
  }

  ::-webkit-scrollbar {
    appearance: none;
    height: 0.45rem;
  }

  ::-webkit-scrollbar-thumb {
    height: 3px;
    background-color: rgba(0, 0, 0, 0.3);
    border: 2px solid white;
    border-radius: 16px;
  }
}

Your environment 🌎

`npx @mui/envinfo`

System:
- OS: macOS 12.2.1
- CPU: (10) arm64 Apple M1 Max
- Memory: 676.78 MB / 32.00 GB
- Shell: 3.2.57 - /bin/bash
Binaries:
- Node: 16.15.1 - /usr/local/bin/node
- npm: 8.1.2 - /usr/local/bin/npm
Managers:
- Homebrew: 3.6.6 - /usr/local/bin/brew
- pip3: 22.3.1 - ~/.pyenv/shims/pip3
- RubyGems: 3.0.3.1 - /usr/bin/gem
Utilities:
- Make: 3.81 - /usr/bin/make
- GCC: 12.3. - /usr/bin/gcc
- Git: 2.37.0 - /usr/local/bin/git
- Clang: 13.0.0 - /usr/bin/clang
Servers:
- Apache: 2.4.51 - /usr/sbin/apachectl
Virtualization:
- Docker: 20.10.17 - /usr/local/bin/docker
IDEs:
- Nano: 2.0.6 - /usr/bin/nano
- Vim: 8.2 - /usr/bin/vim
- Xcode: /undefined - /usr/bin/xcodebuild
Languages:
- Bash: 3.2.57 - /bin/bash
- Go: 1.19.1 - /usr/local/go/bin/go
- Perl: 5.30.3 - /usr/bin/perl
- Python: 3.8.13 - /Users/mattc1221/.pyenv/shims/python
- Python3: 3.8.13 - /Users/mattc1221/.pyenv/shims/python3
- R: 4.2.1 - /usr/local/bin/R
- Ruby: 2.6.8 - /usr/bin/ruby
Databases:
- PostgreSQL: 14.4 - /usr/local/bin/postgres
- SQLite: 3.36.0 - /usr/bin/sqlite3
Browsers:
- Chrome: 108.0.5359.98
- Safari: 15.3

@Mattc1221 Mattc1221 added status: waiting for maintainer These issues haven't been looked at yet by a maintainer support: commercial Support request from paid users labels Dec 15, 2022
@MBilalShafi MBilalShafi added the component: data grid This is the name of the generic UI component, not the React module! label Dec 16, 2022
@m4theushw m4theushw removed the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Dec 16, 2022
@m4theushw
Copy link
Member

Dynamic column width is for when you don't know the width of the content beforehand but knows that maximum width of the container = possible horizontal scrollbar. It seems that in your application you want dynamic column width but also to have the width of the grid equals to the sum of all columns = no horizontal scrollbar. I'm correct? If yes, then it more or less the behavior of autoHeight, but for width, which is not supported yet.

@m4theushw m4theushw changed the title MUI: useResizeContainer - The parent DOM element of the datagird has an empty width. [data grid] MUI: useResizeContainer - The parent DOM element of the data grid has an empty width. Dec 16, 2022
@Mattc1221
Copy link
Author

Mattc1221 commented Dec 16, 2022

@m4theushw

You are correct. However, I have also tried removing that logic and setting a fixed width in the parent component of the DataGrid and am still getting this error message.

@martin-mael
Copy link

martin-mael commented Oct 19, 2023

In my case, I had this issue when I was passing a sortModel to initialState with columns that were not defined (I have multiple DataGrid scenarios, with different columns, so i was passing multiple columns to the initialState). After removing the missing columns, the error was gone !

Before :

initialState={{
  sorting: {
    sortModel: [
      { field: 'account', sort: 'asc' },
      { field: 'counterpart', sort: 'asc' },
      { field: 'date', sort: 'asc' },
     ],
  },
}}

After (initialSortModel passed as prop, with type GridSortItem) :

initialState={{
  sorting: {
    sortModel: initialSortModel && [initialSortModel],
  },
}}

@RobinTail
Copy link

Screenshot 2024-07-25 at 16 32 02

the problem can be the testing environment and the way how MUI detects it — see the /jsdom/ regex on the screenshot above.
In my case, the issue was caused by using HappyDOM instead of JSDOM in vitest (it's faster), but it has to pretend something in config — that fixed it

    environmentOptions: {
      happyDOM: {
        width: 1280,
        height: 1024,
        settings: {
          // @see https://github.com/capricorn86/happy-dom/issues/482#issuecomment-1713338378
          navigator: {
            userAgent: "Mozilla/5.0 HappyDOM/jsdom/compatible", // <— this
          },
        },
      },
    },

@romgrk
Copy link
Contributor

romgrk commented Jul 25, 2024

For the record, having the grid work in jsdom/happy-dom is somewhat hard, those are completely emulated environments that lack some standard browser APIs and features. Those are fine for simple testing, but for real production testing I would recommend playwright or any other headless browser runner.

@Mattc1221 Could you confirm if this issue is still relevant to you? If so, we would need a clear reproduction case to assist with the error.

@romgrk romgrk added the status: waiting for author Issue with insufficient information label Jul 25, 2024
Copy link

github-actions bot commented Aug 2, 2024

The issue has been inactive for 7 days and has been automatically closed.

@github-actions github-actions bot closed this as completed Aug 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: data grid This is the name of the generic UI component, not the React module! status: waiting for author Issue with insufficient information support: commercial Support request from paid users
Projects
None yet
Development

No branches or pull requests

6 participants