@@ -524,27 +524,54 @@ $root: ".widget-datagrid";
524524 }
525525}
526526
527+ // styles for browsers that don't support subgrid
528+ // if the browser doesn't support subgrid
529+ // fall back header an body the contents and apply grid template to the table
530+ .widget-datagrid-grid.table {
531+ grid-template-columns : var (--widgets-grid-template-columns );
532+ }
533+ .widget-datagrid-grid-body ,
527534.widget-datagrid-grid-head {
528- display : grid ;
529- min-width : 0 ;
530-
531- // this head is not part of the grid, so it has dedicated column template --widgets-grid-template-columns-head
532- // but it might not be available at the initial render, so we use template from the grid --widgets-grid-template-columns
533- // using template from the grid might to misalignment from the grid itself,
534- // but in practice:
535- // - grid has no data at that moment, so misalignment is not visible.
536- // - as soon as the grid itself gets rendered --widgets-grid-template-columns-head gets calculated
537- // and everything looks like it should.
538- grid-template-columns : var (--widgets-grid-template-columns-head , var (--widgets-grid-template-columns ));
535+ display : contents ;
539536}
540537
541- .widget-datagrid-grid-body {
542- // this element has to position their children (columns or headers)
543- // as grid and have those aligned with the parent grid
544- display : grid ;
545- // this property makes sure we align our own grid columns
546- // to the columns defined in the global grid
547- grid-template-columns : var (--widgets-grid-template-columns );
538+ // styles for modern browsers
539+ @supports (grid-template-rows : subgrid ) {
540+ .widget-datagrid-grid.table :not ([data-has-scroll-x = " true" ]) {
541+ grid-template-columns : var (--widgets-grid-template-columns );
542+ .widget-datagrid-grid-body ,
543+ .widget-datagrid-grid-head {
544+ display : grid ;
545+ min-width : 0 ;
546+
547+ // this property makes sure we align our own grid columns
548+ // to the columns defined in the global grid
549+ grid-template-columns : subgrid ;
550+
551+ // ensure that we cover all columns of original top level grid
552+ // so our own columns get aligned with the parent
553+ grid-column : 1 / -1 ;
554+ }
555+ }
556+
557+ .widget-datagrid-grid.table [data-has-scroll-x = " true" ] {
558+ // reset the columns defined on table level
559+ // header and body will define their own instead
560+ // this is needed to make body horizontally scrollable
561+ grid-template-columns : initial ;
562+ .widget-datagrid-grid-head {
563+ display : grid ;
564+ min-width : 0 ;
565+
566+ grid-template-columns : var (--widgets-grid-template-columns-head , var (--widgets-grid-template-columns ));
567+ }
568+
569+ .widget-datagrid-grid-body {
570+ display : grid ;
571+
572+ grid-template-columns : var (--widgets-grid-template-columns );
573+ }
574+ }
548575}
549576
550577.grid-mock-header {
0 commit comments