Skip to content

fix: Add Cancel and Add buttons to the add-row modal (#1995)#3383

Open
dblythy wants to merge 1 commit into
parse-community:alphafrom
dblythy:fix/1995-add-row-modal-buttons
Open

fix: Add Cancel and Add buttons to the add-row modal (#1995)#3383
dblythy wants to merge 1 commit into
parse-community:alphafrom
dblythy:fix/1995-add-row-modal-buttons

Conversation

@dblythy

@dblythy dblythy commented Jul 4, 2026

Copy link
Copy Markdown
Member

Closes #1995

Before

Before

After

After

Summary by CodeRabbit

  • New Features

    • Improved the row editor to support creating new entries directly from the dialog.
    • Added clear dialog actions for saving a new row or canceling the add flow.
  • Bug Fixes

    • The editor now closes properly after a new row is saved.
    • Cancel behavior now matches the context: it closes existing items and aborts new-item creation when needed.

@parse-github-assistant

Copy link
Copy Markdown

I will reformat the title to use the proper commit message syntax.

@parse-github-assistant parse-github-assistant Bot changed the title fix: add Cancel and Add buttons to the add-row modal (#1995) fix: Add Cancel and Add buttons to the add-row modal (#1995) Jul 4, 2026
@parse-github-assistant

Copy link
Copy Markdown

🚀 Thanks for opening this pull request! We appreciate your effort in improving the project. Please let us know once your pull request is ready for review.

Tip

  • Keep pull requests small. Large PRs will be rejected. Break complex features into smaller, incremental PRs.
  • Use Test Driven Development. Write failing tests before implementing functionality. Ensure tests pass.
  • Group code into logical blocks. Add a short comment before each block to explain its purpose.
  • We offer conceptual guidance. Coding is up to you. PRs must be merge-ready for human review.
  • Our review focuses on concept, not quality. PRs with code issues will be rejected. Use an AI agent.
  • Human review time is precious. Avoid review ping-pong. Inspect and test your AI-generated code.

Note

Please respond to review comments from AI agents just like you would to comments from a human reviewer. Let the reviewer resolve their own comments, unless they have reviewed and accepted your commit, or agreed with your explanation for why the feedback was incorrect.

Caution

Pull requests must be written using an AI agent with human supervision. Pull requests written entirely by a human will likely be rejected, because of lower code quality, higher review effort and the higher risk of introducing bugs. Please note that AI review comments on this pull request alone do not satisfy this requirement. Our CI and AI review are safeguards, not development tools. If many issues are flagged, rethink your development approach. Invest more effort in planning and design rather than using review cycles to fix low-quality code.

@coderabbitai

coderabbitai Bot commented Jul 4, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This change adds Cancel and Add button behavior to the "Add row with modal" dialog. Browser.react.js closes the edit dialog on successful save and passes new onSaveNewRow/onAbortAddRow callbacks to EditRowDialog, which now conditionally renders Cancel/Add controls based on whether a new object is being created.

Changes

New row modal dialog controls

Layer / File(s) Summary
Browser save/abort handlers and dialog wiring
src/dashboard/Data/Browser/Browser.react.js
saveNewRow now closes the edit dialog on success (showEditRowDialog: false), and renderContent passes new onSaveNewRow/onAbortAddRow callbacks to EditRowDialog.
EditRowDialog Cancel/Add button behavior
src/dashboard/Data/Browser/EditRowDialog.react.js
Adds isNewObject flag and handleCancel logic to call onAbortAddRow() before onClose(); Modal footer now shows conditional "Cancel"/"Close" text and an "Add" continue action wired to onSaveNewRow for new objects.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant EditRowDialog
  participant Browser

  User->>EditRowDialog: Click "Add"
  EditRowDialog->>Browser: onSaveNewRow()
  Browser->>Browser: saveNewRow (update data, close dialog)

  User->>EditRowDialog: Click "Cancel"
  EditRowDialog->>EditRowDialog: handleCancel()
  EditRowDialog->>Browser: onAbortAddRow()
  EditRowDialog->>EditRowDialog: onClose()
Loading

Related issues: #1995 - Adds a "Cancel" button and replaces the ambiguous "Close" button with an "Add" button in the "Add row with modal" dialog.

Suggested labels: enhancement, UI/UX

Suggested reviewers: dblythy, mtrezza

Poem: A rabbit hops to close the row,
No more "Close" to leave you low,
Now "Cancel" waits, and "Add" stands tall,
Two clear paths for one small call. 🐰

🚥 Pre-merge checks | ✅ 6 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is on-topic but missing the required Issue, Approach, and Tasks template sections. Add the template sections for Pull Request, Issue, Approach, and Tasks, and briefly describe the change plus any tests or docs updates.
✅ Passed checks (6 passed)
Check name Status Explanation
Title check ✅ Passed The title matches the requested prefix and accurately summarizes the modal button update.
Linked Issues check ✅ Passed The changes satisfy #1995 by adding Cancel and replacing Close with Add in the add-row modal.
Out of Scope Changes check ✅ Passed The diff stays focused on the modal action behavior and contains no clear unrelated changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Security Check ✅ Passed Only UI state/handler wiring changed; no new unsafe sinks, auth logic, or input handling in the touched files.
Engage In Review Feedback ✅ Passed No actionable review feedback is shown in the PR context; the changes implement the requested modal button behavior.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@dblythy dblythy force-pushed the fix/1995-add-row-modal-buttons branch from 71be7c5 to 7558830 Compare July 4, 2026 15:59
@dblythy

dblythy commented Jul 6, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown
✅ Action performed

Full review finished.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/dashboard/Data/Browser/Browser.react.js (1)

1000-1043: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Stale selection state after successful "Add" leaves incorrect "selected rows" UI state.

addRowWithModal() sets selection = { undefined: true } when opening the modal. Previously, the dialog stayed open after save, so the (unchanged) isJustSavedObject cleanup block in renderContent() (this.setState({ selection: {} }); this.selectRow(selectedId, true);) ran on the next render and fixed the selection.

Now that saveNewRow also sets showEditRowDialog: false in the same state update that nulls newObject, the else if (this.state.showEditRowDialog) branch in renderContent() is skipped once save succeeds, so that cleanup code never runs for the modal-add flow anymore. The stale { undefined: true } selection persists indefinitely, incorrectly driving hasSelectedRows (BrowserFooter) and SelectedRowsNavigationPrompt (selectionCount > 0) after every successful "Add".

Also (lower confidence): in the relation branch, showEditRowDialog: false is applied synchronously right after obj.save() resolves, before the relation-link parent.save() completes — the modal closes before the link is actually confirmed.

🐛 Proposed fix to reset selection on close
-        const state = { data: this.state.data, showEditRowDialog: false };
+        const state = { data: this.state.data, showEditRowDialog: false, selection: {} };
         const relation = this.state.relation;
         if (relation) {
           const parent = relation.parent;
           const parentRelation = parent.relation(relation.key);
           parentRelation.add(obj);
           const targetClassName = relation.targetClassName;
           parent.save(null, { useMasterKey }).then(
             () => {
               this.setState({
                 newObject: null,
                 data: [obj, ...this.state.data],
+                selection: { [obj.id]: true },
                 relationCount: this.state.relationCount + 1,
                 counts: {
                   ...this.state.counts,
                   [targetClassName]: this.state.counts[targetClassName] + 1,
                 },
               });
             },
             error => {
               ...
             }
           );
         } else {
           state.newObject = null;
           if (this.props.params.className === obj.className) {
             this.state.data.unshift(obj);
+            state.selection = { [obj.id]: true };
           }
           this.state.counts[obj.className] += 1;
         }

         this.setState(state);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/dashboard/Data/Browser/Browser.react.js` around lines 1000 - 1043, The
Add modal flow in Browser.react.js now closes before the old selection cleanup
in renderContent() can run, so the stale selection from addRowWithModal() is
never cleared after a successful save. Update the save success path in
saveNewRow()/the obj.save() handler to explicitly reset selection when closing
the dialog (and do the same in the relation branch once the parent.save()
completes), using the existing state/update logic around showEditRowDialog,
selection, and selectRow so BrowserFooter and SelectedRowsNavigationPrompt no
longer see a phantom selected row.
🧹 Nitpick comments (1)
src/dashboard/Data/Browser/EditRowDialog.react.js (1)

227-245: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider adding test coverage for the new Cancel/Add modal behavior.

This introduces new interactive states (isNewObject, conditional Cancel/Close text, conditional Add button) with no accompanying test changes in the provided files. Given the stale-selection regression found in Browser.react.js's saveNewRow (see comment there), a test exercising "add row via modal → Add" would have caught it.

Also applies to: 515-521

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/dashboard/Data/Browser/EditRowDialog.react.js` around lines 227 - 245,
Add test coverage for the new modal state handling in EditRowDialog.react.js,
especially the isNewObject-driven Cancel/Add behavior and handleCancel flow.
Update or add tests around EditRowDialog and the add-row path in
Browser.react.js’s saveNewRow to exercise “add row via modal → Add” and confirm
the selected object/row state stays in sync. Make sure the test checks the
conditional button text and that Cancel calls onAbortAddRow only for new rows
while still closing the dialog.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@src/dashboard/Data/Browser/Browser.react.js`:
- Around line 1000-1043: The Add modal flow in Browser.react.js now closes
before the old selection cleanup in renderContent() can run, so the stale
selection from addRowWithModal() is never cleared after a successful save.
Update the save success path in saveNewRow()/the obj.save() handler to
explicitly reset selection when closing the dialog (and do the same in the
relation branch once the parent.save() completes), using the existing
state/update logic around showEditRowDialog, selection, and selectRow so
BrowserFooter and SelectedRowsNavigationPrompt no longer see a phantom selected
row.

---

Nitpick comments:
In `@src/dashboard/Data/Browser/EditRowDialog.react.js`:
- Around line 227-245: Add test coverage for the new modal state handling in
EditRowDialog.react.js, especially the isNewObject-driven Cancel/Add behavior
and handleCancel flow. Update or add tests around EditRowDialog and the add-row
path in Browser.react.js’s saveNewRow to exercise “add row via modal → Add” and
confirm the selected object/row state stays in sync. Make sure the test checks
the conditional button text and that Cancel calls onAbortAddRow only for new
rows while still closing the dialog.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 08c6b35f-71a4-4848-8c98-76bcafc1306b

📥 Commits

Reviewing files that changed from the base of the PR and between 9db24be and 7558830.

📒 Files selected for processing (2)
  • src/dashboard/Data/Browser/Browser.react.js
  • src/dashboard/Data/Browser/EditRowDialog.react.js

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.

"Add row with modal" dialog has no cancel button

1 participant