Skip to content

Commit 190e09b

Browse files
committed
Fix dirty marker and Reset All button styling issues
- Fix _update_groupbox_dirty_markers to only consider fields under current nested manager's prefix instead of all fields in state - Fix Reset All button styling to use font underline instead of underscore character for signature diff indication Bug fixes for nested form manager dirty state tracking
1 parent 1f129dd commit 190e09b

2 files changed

Lines changed: 24 additions & 8 deletions

File tree

src/pyqt_reactive/forms/parameter_form_manager.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -809,18 +809,32 @@ def _update_reset_button_styling(self, param_name: str) -> None:
809809
update_reset_button_styling(reset_button, self.state, self.field_id, param_name)
810810

811811
def _update_groupbox_dirty_markers(self) -> None:
812-
"""Update groupbox dirty markers (title and Reset All button)."""
812+
"""Update groupbox dirty markers (title and Reset All button).
813+
814+
CRITICAL: Only consider fields under THIS nested manager's prefix.
815+
The state contains ALL fields, so we must filter by field_id prefix.
816+
"""
813817
# Find the groupbox widget for this manager
814818
groupbox = None
815819
if self._parent_manager:
816820
for name, nested in self._parent_manager.nested_managers.items():
817821
if nested is self:
818822
groupbox = self._parent_manager.widgets.get(name)
819823
break
820-
824+
821825
if groupbox and hasattr(groupbox, 'set_dirty_marker'):
822-
has_dirty = bool(self.state.dirty_fields)
823-
has_sig_diff = bool(self.state.signature_diff_fields)
826+
# Filter dirty_fields and signature_diff_fields to only include
827+
# fields under this nested manager's prefix (field_id)
828+
prefix = self.field_id + '.' if self.field_id else ''
829+
830+
if prefix:
831+
has_dirty = any(f.startswith(prefix) for f in self.state.dirty_fields)
832+
has_sig_diff = any(f.startswith(prefix) for f in self.state.signature_diff_fields)
833+
else:
834+
# Root manager - check all fields
835+
has_dirty = bool(self.state.dirty_fields)
836+
has_sig_diff = bool(self.state.signature_diff_fields)
837+
824838
groupbox.set_dirty_marker(has_dirty, has_sig_diff)
825839

826840
def _update_provenance_button_visibility(self) -> None:

src/pyqt_reactive/widgets/shared/clickable_help_components.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,16 +1051,18 @@ def set_dirty_marker(self, is_dirty: bool, has_sig_diff: bool = False) -> None:
10511051
self._update_reset_all_button_styling(is_dirty, has_sig_diff)
10521052

10531053
def _update_reset_all_button_styling(self, is_dirty: bool, has_sig_diff: bool) -> None:
1054-
"""Update Reset All button with * and _ styling."""
1054+
"""Update Reset All button with * and _ styling.
1055+
1056+
* prefix indicates dirty (unsaved changes)
1057+
Underline (via font) indicates signature diff (differs from signature default)
1058+
"""
10551059
button = self._reset_all_button
10561060
text = "Reset All"
10571061
if is_dirty:
10581062
text = "*" + text
1059-
if has_sig_diff:
1060-
text = "_" + text
10611063
button.setText(text)
10621064

1063-
# Apply underline via font (independent of dirty)
1065+
# Apply underline via font (NOT as literal underscore character)
10641066
font = button.font()
10651067
font.setUnderline(has_sig_diff)
10661068
button.setFont(font)

0 commit comments

Comments
 (0)