Skip to content

Fix alternative criteria reordering when adding second alternative - #63

Merged
AAClause merged 1 commit into
developfrom
bugfix/second_alternative
Sep 2, 2026
Merged

Fix alternative criteria reordering when adding second alternative#63
AAClause merged 1 commit into
developfrom
bugfix/second_alternative

Conversation

@AAClause

Copy link
Copy Markdown
Member
  • Explicitly show sequence order controls when nbAlternatives > 1
  • Use valid default index (nbAlternatives - 1) instead of out-of-range value
  • Add bounds validation for criteriaIndex before setting selection

Fixes issue where entering data for a new alternative and changing its
order would cause the data to be lost, duplicating the existing alternative's
data instead.

Fixes #62

@AAClause
AAClause marked this pull request as ready for review September 2, 2026 17:10
@AAClause
AAClause force-pushed the bugfix/second_alternative branch 3 times, most recently from 8c686b0 to b79cecd Compare September 2, 2026 17:35
When a rule has exactly one alternative, the Rule Editor uses "Simple
Mode" and edits it through SimpleSingleNodeCriteriaPanel, whose
getData() always targets criteria[0]. Clicking "Add alternatives"
correctly inserts the new alternative into the rule's criteria list,
then calls RuleEditorDialog.switchToFullEditor() to reload the dialog
in full mode. That method unconditionally flushes the currently shown
(now stale) single-node panel via updateData(), which writes its
widget values -- still reflecting the previous sole alternative -- into
criteria[0]. If the new alternative was reordered to the first
position, this silently overwrites its freshly entered data with the
old alternative's data. Left at the default last position, criteria[0]
is still the old alternative, so the overwrite is a no-op, which is
why the bug only surfaced when reordering a newly added second
alternative to position 1.

Fix switchToFullEditor() to accept an opt-out for this flush, and use
it from the alternative-creation path where the data has already been
persisted through the Criteria Set editor and must not be re-flushed
from the stale panel.

Also fix the Criteria Set editor's sequence order default, which used
an out-of-range fallback constant (nbAlternatives + 1) instead of the
last valid position (nbAlternatives - 1).

Fixes #62
@AAClause
AAClause force-pushed the bugfix/second_alternative branch from b79cecd to 90009de Compare September 2, 2026 18:11
@AAClause
AAClause merged commit 05ac89d into develop Sep 2, 2026
@AAClause
AAClause deleted the bugfix/second_alternative branch September 2, 2026 18:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Adding a new alternative to a rule with one existing alternative loses entered data when reordering

1 participant