Skip to content

Conversation

mtrezza
Copy link
Member

@mtrezza mtrezza commented Oct 5, 2025

New Pull Request Checklist

Issue Description

When rows are selected while trying to changing the data browser table data, the alert is not displayed in the following cases:

  • Applying / modifying filter
  • Clicking the page arrows in the navigation bar
  • Entering a page number in the navigation bar
  • Selecting an item in the "obj per page" drop-down

Approach

Show alert in above cases.

Summary by CodeRabbit

  • New Features
    • Added a confirmation prompt when changing filters, page, or page size while rows are selected to prevent accidental loss of selections.
    • If the prompt is canceled, the current view and selections remain unchanged.
    • The footer now reflects when rows are selected and respects the selection state during pagination and limit changes, improving clarity and control.

Copy link

parse-github-assistant bot commented Oct 5, 2025

🚀 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.

Copy link

coderabbitai bot commented Oct 5, 2025

📝 Walkthrough

Walkthrough

Adds confirmation guards when rows are selected: updateFilters in Browser prompts and may abort; Browser passes hasSelectedRows and selectedRowsMessage props to BrowserFooter; BrowserFooter adds similar guards for limit and page changes, early-returning on user cancel.

Changes

Cohort / File(s) Summary
Data Browser component
src/dashboard/Data/Browser/Browser.react.js
Inserted confirmation guard in updateFilters to block filter changes when rows are selected unless confirmed. Passed new props to footer: hasSelectedRows, selectedRowsMessage.
Browser footer component
src/dashboard/Data/Browser/BrowserFooter.react.js
Added confirmation guards in handleLimitChange and handlePageChange; early return on cancel. Maintains existing logic to parse/apply limit, reset skip, and sync page input when confirmed.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor U as User
  participant B as Browser.react
  participant D as Confirm Dialog
  note over B: updateFilters
  U->>B: Change filter
  alt Rows selected
    B->>D: Prompt with SELECTED_ROWS_MESSAGE
    D-->>B: Cancel
    B-->>U: Abort filter change
  else No rows selected or confirmed
    B-->>U: Apply new filters
  end
Loading
sequenceDiagram
  autonumber
  actor U as User
  participant F as BrowserFooter.react
  participant B as Browser.react
  participant D as Confirm Dialog
  rect rgba(230,240,255,0.4)
  note right of F: handleLimitChange / handlePageChange
  U->>F: Change limit or page
  alt hasSelectedRows
    F->>D: Prompt with selectedRowsMessage
    D-->>F: Cancel
    F-->>U: Abort change
  else Not selected or confirmed
    F->>B: Update limit/skip and page input
    B-->>F: Props/state updated
  end
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The description follows the repository template but leaves the “Closes” field as FILL_THIS_OUT and omits any details in the Approach section, so it lacks the required issue reference and implementation summary. Please specify the issue number in the “Closes” field, add a concise summary of the implementation under Approach, and update or remove the TODOs after adding tests and documentation.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The title accurately reflects the core change—adding an alert when modifying the data browser with selected rows—and aligns with the pull request’s intent, although its wording is somewhat verbose and contains a duplication that could be streamlined.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@parseplatformorg
Copy link
Contributor

🎉 Snyk checks have passed. No issues have been found so far.

security/snyk check is complete. No issues have been found. (View Details)

@mtrezza mtrezza changed the title fix: Missing alert on navigation fix: Missing alert when changing data browser browser data while rows are selected Oct 5, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

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/BrowserFooter.react.js (1)

21-30: Potential state synchronization issue with page input.

When validateAndApplyPage (line 50) calls handlePageChange, it sets pageInput state before the confirmation prompt. If the user has selected rows and cancels the confirmation in handlePageChange, the input field will display the new page number while the data still shows the old page.

The flow is:

  1. User types a page number and presses Enter
  2. validateAndApplyPage sets pageInput state to the new value (line 60)
  3. validateAndApplyPage calls handlePageChange (line 61)
  4. User cancels the confirmation
  5. handlePageChange returns early (line 36)
  6. Result: pageInput shows the new page, but skip remains unchanged

Apply this diff to fix the synchronization:

 validateAndApplyPage = () => {
   const { limit, count } = this.props;
   let newPage = parseInt(this.state.pageInput, 10);

   if (isNaN(newPage) || newPage < 1) {
     newPage = 1;
   } else if (newPage > Math.ceil(count / limit)) {
     newPage = Math.ceil(count / limit);
   }

-  this.setState({ pageInput: newPage.toString() });
-  this.handlePageChange((newPage - 1) * limit);
+  const newSkip = (newPage - 1) * limit;
+  if (newSkip >= 0 && newSkip < count) {
+    if (this.props.hasSelectedRows && !window.confirm(this.props.selectedRowsMessage)) {
+      // Reset input to current page on cancel
+      this.setState({ pageInput: (Math.floor(this.props.skip / limit) + 1).toString() });
+      return;
+    }
+    this.props.setSkip(newSkip);
+    this.setState({ pageInput: newPage.toString() });
+  }
+  
+  const table = document.getElementById('browser-table');
+  table.scrollTo({ top: 0 });
 };

Alternatively, move the pageInput state update to after the confirmation succeeds in handlePageChange.

🧹 Nitpick comments (2)
src/dashboard/Data/Browser/BrowserFooter.react.js (1)

32-44: Consider extracting duplicate scroll logic.

The table scroll behavior (lines 42-43) occurs after the conditional skip update. If the bounds check fails (newSkip < 0 or newSkip >= count), the table still scrolls to top even though no page change occurred.

While this is existing behavior, consider moving the scroll logic inside the conditional block to ensure it only executes when the page actually changes:

 handlePageChange = newSkip => {
   if (newSkip >= 0 && newSkip < this.props.count) {
     // Check if there are selected rows
     if (this.props.hasSelectedRows && !window.confirm(this.props.selectedRowsMessage)) {
       return;
     }
     this.props.setSkip(newSkip);
     this.setState({ pageInput: (Math.floor(newSkip / this.props.limit) + 1).toString() });
+    
+    const table = document.getElementById('browser-table');
+    table.scrollTo({ top: 0 });
   }
-
-  const table = document.getElementById('browser-table');
-  table.scrollTo({ top: 0 });
 };
src/dashboard/Data/Browser/Browser.react.js (1)

1454-1471: Consider adding confirmation when changing sort order.

The updateOrdering method clears the selection (line 1459) without prompting the user, which differs from the pattern established in updateFilters, handleLimitChange, and handlePageChange. Users might expect a warning since their selection is being discarded.

However, this may be intentional since re-sorting is a view operation within the current page rather than navigation. If you decide consistency is preferred, apply this diff:

 updateOrdering(ordering) {
+  if (Object.keys(this.state.selection).length > 0) {
+    if (!window.confirm(SELECTED_ROWS_MESSAGE)) {
+      return;
+    }
+  }
   const source = this.state.relation || this.props.params.className;
   this.setState(
     {
       ordering: ordering,
       selection: {},
       errorAggregatedData: {},
       isLoadingInfoPanel: false,
       AggregationPanelData: {},
     },
     () => this.fetchData(source, this.state.filters)
   );
   ColumnPreferences.getColumnSort(
     ordering,
     this.context.applicationId,
     this.props.params.className
   );
 }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ddbb63b and adabfc9.

📒 Files selected for processing (2)
  • src/dashboard/Data/Browser/Browser.react.js (2 hunks)
  • src/dashboard/Data/Browser/BrowserFooter.react.js (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Node 18
  • GitHub Check: Node 20
  • GitHub Check: Docker linux/amd64
🔇 Additional comments (3)
src/dashboard/Data/Browser/Browser.react.js (3)

49-118: LGTM! Well-implemented navigation guard.

The SelectedRowsNavigationPrompt component correctly handles multiple navigation scenarios:

  • Browser navigation (beforeunload, popstate)
  • Link clicks with proper filtering (ignoring modified clicks, external links, etc.)
  • Integration with React Router's useBeforeUnload

The implementation prevents unintended navigation when rows are selected.


1248-1291: LGTM! Confirmation guard correctly prevents filter loss.

The guard in updateFilters properly checks for selected rows and prompts for confirmation before applying new filters, which would clear the selection. The early return on cancel prevents the filter update.


2526-2540: Props correctly passed to BrowserFooter.

The hasSelectedRows boolean and selectedRowsMessage string are computed and passed appropriately, enabling the footer to enforce the selected-rows guard.

@mtrezza mtrezza merged commit 6cabaa3 into parse-community:alpha Oct 5, 2025
11 checks passed
@mtrezza mtrezza changed the title fix: Missing alert when changing data browser browser data while rows are selected fix: Missing alert when changing data browser table data while rows are selected Oct 5, 2025
@mtrezza mtrezza deleted the fix/missing-alert-on-navigation branch October 5, 2025 10:24
parseplatformorg pushed a commit that referenced this pull request Oct 5, 2025
# [7.6.0-alpha.4](7.6.0-alpha.3...7.6.0-alpha.4) (2025-10-05)

### Bug Fixes

* Missing alert when changing data browser browser data while rows are selected ([#2994](#2994)) ([6cabaa3](6cabaa3))
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 7.6.0-alpha.4

@parseplatformorg parseplatformorg added the state:released-alpha Released as alpha version label Oct 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state:released-alpha Released as alpha version
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants