Repository navigation
fix(dashboard): keep condition names editable after deleting a row - #804
wozhenbang2004 wants to merge 2 commits into
Conversation
Aias00
left a comment
There was a problem hiding this comment.
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, becausevalue={item.paramName ?? ""}always supplies the same string. The new tests only locate the field throughgetByPlaceholderText, so they would break if the dead placeholder were dropped; consider removing it and querying the field by row/role instead.conditionChangestill mutatesconditions[index][name]and callssetStatewith the same array reference. That works today becauseAddModalis a plainComponent, 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.jsandRule.import.test.jsagainst887f2300b0bab9d5c7a04f68ae42a451550b087e, plussrc/utils/conditionDraft.js,src/components/ui/Input.jsand.github/workflows/build.ymlat7afd5de08f7c71a4eb0a96cfaa7e4cb7a2377990. - No
paramTypeValueEnreferences remain at the head revision, andFIXED_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.paramNamenormalization keepsreq_method/domainrows 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
7afd5de0yet, so the new tests are verified by reading only; CI (npm run test:coverage,npm run lint) will confirm them.
|
@wozhenbang2004 pls fix conflicts |
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
After