diff --git a/.gitignore b/.gitignore index 5e0e0fc..865171c 100644 --- a/.gitignore +++ b/.gitignore @@ -25,6 +25,7 @@ tools.db .idea_bak **/*.prof **/*.db +screenshot* # Created by .ignore support plugin (hsz.mobi) ### Python template diff --git a/src/myfasthtml/assets/datagrid/datagrid.css b/src/myfasthtml/assets/datagrid/datagrid.css index 420bb5f..e755403 100644 --- a/src/myfasthtml/assets/datagrid/datagrid.css +++ b/src/myfasthtml/assets/datagrid/datagrid.css @@ -161,9 +161,10 @@ .dt2-table { --color-border: color-mix(in oklab, var(--color-base-content) 20%, #0000); --color-resize: color-mix(in oklab, var(--color-base-content) 50%, #0000); - height: 100%; + height: fit-content; + max-height: 100%; display: grid; - grid-template-rows: auto 1fr auto; /* header, body, footer */ + grid-template-rows: auto minmax(auto, 1fr) auto; /* header, body, footer */ overflow-x: auto; /* Enable horizontal scroll */ overflow-y: hidden; /* No vertical scroll on table */ scrollbar-width: none; /* Firefox: hide scrollbar */ @@ -225,6 +226,11 @@ width: 8px; } +/* Extra row reserved when horizontal scrollbar is visible */ +.dt2-table.dt2-has-hscroll { + grid-template-rows: auto minmax(auto, 1fr) auto 8px; /* header, body, footer, scrollbar */ +} + /* Horizontal scrollbar wrapper - bottom, full width minus vertical scrollbar */ .dt2-scrollbars-horizontal-wrapper { left: 0; diff --git a/src/myfasthtml/assets/datagrid/datagrid.js b/src/myfasthtml/assets/datagrid/datagrid.js index b762149..de25794 100644 --- a/src/myfasthtml/assets/datagrid/datagrid.js +++ b/src/myfasthtml/assets/datagrid/datagrid.js @@ -225,6 +225,7 @@ function initDataGridScrollbars(gridId) { // PHASE 3: Write all DOM properties (already in RAF) verticalWrapper.style.display = isVerticalRequired ? "block" : "none"; horizontalWrapper.style.display = isHorizontalRequired ? "block" : "none"; + table.classList.toggle("dt2-has-hscroll", isHorizontalRequired && isVerticalRequired); verticalScrollbar.style.height = `${scrollbarHeight}px`; horizontalScrollbar.style.width = `${scrollbarWidth}px`; verticalScrollbar.style.top = `${verticalTop}px`; @@ -631,7 +632,10 @@ function moveColumn(table, sourceColId, targetColId) { function updateDatagridSelection(datagridId) { const selectionManager = document.getElementById(`tsm_${datagridId}`); - if (!selectionManager) return; + if (!selectionManager) { + console.warn(`DataGrid selection manager not found for ${datagridId}`); + return; + } // Re-enable tooltips after drag const wrapper = document.getElementById(`tw_${datagridId}`);