There is a known behaviour with cs grid where if the content of the cell is larger than the computed layout cell size, the cell expands. Meaning your grid is only a fixed size if the content is less than or equal to the cell size.
There are several workarounds for this that involve you changing the style for the grid and cells themselves.
However, I have noticed that these workarounds are not necessary when I use a 3rd party control (e.g MUI List), where all you have to do is set overflow: 'auto' on the actual control itself. You don't have to mess with the parent grid.
So my question is. How do I go about making a control that will switch to a scrollviewer if its content is too large to be displayed inside a grid cell. i.e I don't want to mess with the parent grid every time I want to use my control in a new place.
Below I have included a fiddle that shows the issue and the workaround. But I would to know how to fix it without messing with grid cells, as per the case when using 3rd party controls
https://jsfiddle.net/8b074ung/11/
.grid {
display: grid;
grid-template-columns: repeat(2, 1fr);
width: 800px;
height: 300px;
}
.cell {
background: red;
margin: 10px;
/* min-width: 0;
min-height: 0;
display: flex;
flex-direction: row; */
}
.scrollable {
background: orange;
margin: 10px;
overflow: auto;
}
.row {
background: purple;
display: grid;
grid-auto-flow: column;
width: max-content;
}
.item {
width: 100px;
height: 100px;
margin: 5px;
background: green;
}
<div class="grid">
<div class="cell">
<div class="scrollable">
<div class='row'>
<div class='item'></div>
<div class='item'></div>
<div class='item'></div>
<div class='item'></div>
<div class='item'></div>
</div>
</div>
</div>
<div class="cell">
</div>
</div>