From 09516804664c524627802aee46bcbf4ad25b33c5 Mon Sep 17 00:00:00 2001 From: Kodjo Sossouvi Date: Sun, 15 Mar 2026 18:45:55 +0100 Subject: [PATCH] Fixed minor issues. * highlighted cells not correctly rendered * text selection not correctly working --- src/myfasthtml/assets/datagrid/datagrid.js | 6 +++--- src/myfasthtml/controls/DataGrid.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/myfasthtml/assets/datagrid/datagrid.js b/src/myfasthtml/assets/datagrid/datagrid.js index 9e9a891..922e27e 100644 --- a/src/myfasthtml/assets/datagrid/datagrid.js +++ b/src/myfasthtml/assets/datagrid/datagrid.js @@ -673,9 +673,9 @@ function updateDatagridSelection(datagridId) { // Clear browser text selection to prevent stale ranges from reappearing // But skip if an input/textarea/contenteditable has focus (would clear text cursor) - if (!document.activeElement?.closest('input, textarea, [contenteditable]')) { - window.getSelection()?.removeAllRanges(); - } + // if (!document.activeElement?.closest('input, textarea, [contenteditable]')) { + // window.getSelection()?.removeAllRanges(); + // } // OPTIMIZATION: scope to table instead of scanning the entire document const table = document.getElementById(`t_${datagridId}`); diff --git a/src/myfasthtml/controls/DataGrid.py b/src/myfasthtml/controls/DataGrid.py index 562c9a3..9b99d3a 100644 --- a/src/myfasthtml/controls/DataGrid.py +++ b/src/myfasthtml/controls/DataGrid.py @@ -794,7 +794,7 @@ class DataGrid(MultipleInstance): res.append(Span(value_str[:index], cls=f"{css_class}")) res.append(Span(value_str[index:index + len_keyword], cls="dt2-highlight-1")) if index + len_keyword < len(value_str): - res.append(Span(value_str[index + len_keyword:], cls=f"{css_class}")) + res.append(Span(value_str[index + len_keyword:])) return Span(*res, cls=f"{css_class} truncate", style=style) if len(res) > 1 else res[0]