Skip to content

fix(dashboard): keep condition names editable after deleting a row - #804

Open
wozhenbang2004 wants to merge 2 commits into
apache:masterfrom
wozhenbang2004:fix/condition-name-after-delete
Open

wozhenbang2004 wants to merge 2 commits into
apache:masterfrom
wozhenbang2004:fix/condition-name-after-delete

Conversation

@wozhenbang2004

Copy link
Copy Markdown
Contributor

Fixes #801.

Show the name field based on the current condition's type and bind the input to that row's value in both editors. Delete the URI condition, edit the remaining Header name, and save. The form now submits the edited name.

Before

Before

After

After

Aias00
Aias00 previously approved these changes Dec 1, 2026

@Aias00 Aias00 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.

Approve. No blocking findings.

Removing the index-based paramTypeValueEn${index} flags is the right fix: the name column now derives from item.paramType and the input is controlled by item.paramName, so it can no longer go stale after a row is removed. I traced the reported repro (URI + Header, delete the URI row, edit the Header name, save): the surviving row keeps its own type and name, conditionChange writes paramName, and checkConditions accepts the submitted value. The new keeps the remaining condition name editable after removing a preceding row tests fail on the base revision for the expected reason (paramTypeValueEn0 is still true for the row that moved to index 0, and the uncontrolled input still shows the old text).

Non-blocking suggestions

  • placeholder={item.paramName} can no longer be displayed, because value={item.paramName ?? ""} always supplies the same string. The new tests only locate the field through getByPlaceholderText, so they would break if the dead placeholder were dropped; consider removing it and querying the field by row/role instead.
  • conditionChange still mutates conditions[index][name] and calls setState with the same array reference. That works today because AddModal is a plain Component, but the rendered name value and the column visibility now both depend on that re-render; an immutable update (map + spread) would drop the hidden dependency on always-render semantics.

Verification

  • Read the full diff for Rule.js, Selector.js, RuleEditor.test.js, SelectorEditor.test.js and Rule.import.test.js against 887f2300b0bab9d5c7a04f68ae42a451550b087e, plus src/utils/conditionDraft.js, src/components/ui/Input.js and .github/workflows/build.yml at 7afd5de08f7c71a4eb0a96cfaa7e4cb7a2377990.
  • No paramTypeValueEn references remain at the head revision, and FIXED_PARAM_TYPES (uri, host, ip, req_method, domain) is exactly the type list the removed flags covered, so no condition type changes visibility; the extra !item.paramName normalization keeps req_method/domain rows submittable now that their name field is hidden.
  • I did not execute the Jest suite, and no check runs or commit statuses are reported for 7afd5de0 yet, so the new tests are verified by reading only; CI (npm run test:coverage, npm run lint) will confirm them.

@Aias00

Aias00 commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

@wozhenbang2004 pls fix conflicts

This branch has not been deployed

No deployments
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.

[BUG] Deleting a condition hides the next condition's parameter name

2 participants