Skip to content

Fix duplicate data-index values in property editor add/save handlers - #13

Merged
matteius merged 4 commits into
mainfrom
copilot/fix-comments-from-review-thread
Aug 3, 2026
Merged

Fix duplicate data-index values in property editor add/save handlers#13
matteius merged 4 commits into
mainfrom
copilot/fix-comments-from-review-thread

Conversation

Copilot AI commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

The "Add Condition/Validation/Dependency" click handlers captured the array .length at listener-registration time as the new row's data-index. After any add or delete, subsequent clicks produced duplicate indices, causing save-time lookups to read the wrong row's data.

Changes

  • Click handlers — compute the next index at click time by counting current .card elements in the container instead of closing over the stale array length:

    btnAdd.addEventListener('click', () => {
        const nextIndex = container.querySelectorAll('.card').length;
        this.addConditionRow({}, nextIndex);
    });
  • Save-time loops — replace the forEach enumeration index with el.dataset.index so lookups match the actual data-index attribute on each row, regardless of insertion/deletion history:

    document.querySelectorAll('.condition-field').forEach((el) => {
        const index = el.dataset.index;  // was: forEach counter
        const operator = document.querySelector(`.condition-operator[data-index="${index}"]`).value;
        ...
    });

Affects all three tabs: Conditional Logic, Validation Rules, and Dependencies.

Copilot AI review requested due to automatic review settings August 3, 2026 20:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because there is no eligible user to bill. To allow Copilot reviews on bot-authored pull requests, enable direct organization billing in your organization's Copilot settings.

Co-authored-by: matteius <479892+matteius@users.noreply.github.com>
Copilot AI review requested due to automatic review settings August 3, 2026 20:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because there is no eligible user to bill. To allow Copilot reviews on bot-authored pull requests, enable direct organization billing in your organization's Copilot settings.

Co-authored-by: matteius <479892+matteius@users.noreply.github.com>
Copilot AI review requested due to automatic review settings August 3, 2026 20:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because there is no eligible user to bill. To allow Copilot reviews on bot-authored pull requests, enable direct organization billing in your organization's Copilot settings.

Copilot AI changed the title [WIP] Fix code based on review comments Fix duplicate data-index values in property editor add/save handlers Aug 3, 2026
Copilot AI requested a review from matteius August 3, 2026 20:21
@matteius

matteius commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

@copilot resolve the merge conflicts in this pull request

Co-authored-by: matteius <479892+matteius@users.noreply.github.com>
Copilot AI review requested due to automatic review settings August 3, 2026 20:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because there is no eligible user to bill. To allow Copilot reviews on bot-authored pull requests, enable direct organization billing in your organization's Copilot settings.

Copilot AI commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

@copilot resolve the merge conflicts in this pull request

Resolved. Merged main into the branch — the four conflicted files (form-builder-property-editor.js, form-builder.js, and two test files) are now reconciled, with the bug fixes from this PR applied on top of the latest main. All 109 tests pass.

@matteius
matteius marked this pull request as ready for review August 3, 2026 20:27
@matteius
matteius merged commit d839e57 into main Aug 3, 2026
7 checks passed
@matteius
matteius deleted the copilot/fix-comments-from-review-thread branch August 3, 2026 20:27
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.

3 participants