From fc38196ad9cfc74b01f88dec87d58e55527f150a Mon Sep 17 00:00:00 2001 From: Kodjo Sossouvi Date: Sat, 7 Feb 2026 23:03:14 +0100 Subject: [PATCH] Fixed issue where table rules were not applied --- src/myfasthtml/controls/DataGridFormattingEditor.py | 4 ++-- tests/controls/test_datagrid_formatting.py | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/myfasthtml/controls/DataGridFormattingEditor.py b/src/myfasthtml/controls/DataGridFormattingEditor.py index 3891285..25a8a51 100644 --- a/src/myfasthtml/controls/DataGridFormattingEditor.py +++ b/src/myfasthtml/controls/DataGridFormattingEditor.py @@ -80,10 +80,10 @@ class DataGridFormattingEditor(DslEditor): cells_rules[cell_id].append(rule) elif isinstance(scope, TableScope): # Validate table name matches current grid - if scope.table == self._parent._settings.name: + if scope.table == self._parent.get_table_name(): table_rules.append(rule) else: - logger.warning(f"Table name '{scope.table}' does not match grid name '{self._parent._settings.name}', skipping rules") + logger.warning(f"Table name '{scope.table}' does not match grid name '{self._parent.get_table_name()}', skipping rules") elif isinstance(scope, TablesScope): tables_rules.append(rule) diff --git a/tests/controls/test_datagrid_formatting.py b/tests/controls/test_datagrid_formatting.py index d2dd0e5..c782b81 100644 --- a/tests/controls/test_datagrid_formatting.py +++ b/tests/controls/test_datagrid_formatting.py @@ -172,7 +172,7 @@ class TestFormattingEditorIntegration: """Test that table rules are dispatched to DatagridState.table_format.""" dsl = ''' -table "products": +table "app.products": style("info") ''' editor.set_content(dsl) @@ -218,7 +218,7 @@ tables: tables: style(font_size="14px") -table "products": +table "app.products": format.number(precision=2) column amount: @@ -244,7 +244,7 @@ cell (amount, 1): """Test that table_format is cleared when DSL changes.""" # First set table rules dsl = ''' -table "products": +table "app.products": style("info") ''' editor.set_content(dsl) @@ -257,10 +257,10 @@ table "products": assert len(datagrid._state.table_format) == 0 @pytest.mark.parametrize("table_name,should_apply", [ - ("products", True), # Correct name + ("app.products", True), # Correct name (namespace.name) + ("products", False), # Name only (namespace required) ("PRODUCTS", False), # Case sensitive ("product", False), # Partial match not allowed - ("app.products", False), # Namespace not included ("other", False), # Completely wrong ]) def test_table_name_validation(self, datagrid, editor, table_name, should_apply):