Skip to content

Conversation

mtrezza
Copy link
Member

@mtrezza mtrezza commented Oct 14, 2025

New Pull Request Checklist

Issue Description

When hitting the Esc key while editing a cell in the DataBrowser table, the editing does not abort.

Approach

According to MDN Web Docs, the keypress event is deprecated:

Deprecated: This feature is no longer recommended. The keydown and beforeinput events should be used instead.

So this change also modernizes the code to follow current web standards.

The root cause chain was:

  • StringEditor listened to keypress events
  • User presses Escape key
  • Browser doesn't fire keypress event for Escape
  • handleKey never gets called
  • Escape key handling code never executes
  • Editing doesn't abort

By changing to keydown:

  • StringEditor now listens to keydown events
  • User presses Escape key
  • Browser fires keydown event for Escape ✅
  • handleKey gets called ✅
  • Escape key handling code executes ✅
  • Editing aborts as expected ✅

Summary by CodeRabbit

  • New Features

    • Press Esc to cancel edits in text, number, date/time, and geo point fields without saving.
  • Improvements

    • More consistent keyboard behavior using key-down; Enter-to-commit is smoother and predictable.
    • Better mobile usability: external taps are recognized for cancel/commit.
    • Cancel action is now supported across all editors, including complex field types.
  • Bug Fixes

    • Prevents unintended browser actions when pressing Enter or Esc.
    • More reliable focus behavior between latitude and longitude inputs.

Copy link

parse-github-assistant bot commented Oct 14, 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.

@parseplatformorg
Copy link
Contributor

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

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

Copy link

coderabbitai bot commented Oct 14, 2025

📝 Walkthrough

Walkthrough

Adds ESC/cancel handling and switches key listeners from keypress/click to keydown/touchend across editors. Introduces an optional onCancel prop for DateTimeEditor and propagates onCancel through Browser.Editor to all editor types. Updates mount/unmount listeners accordingly and adjusts Enter key paths to prevent default behavior.

Changes

Cohort / File(s) Summary
Keyboard event model update
src/components/DateTimeEditor/DateTimeEditor.react.js, src/components/GeoPointEditor/GeoPointEditor.react.js, src/components/NumberEditor/NumberEditor.react.js, src/components/StringEditor/StringEditor.react.js
Replace keypress with keydown; replace body click with touchend for external-interaction checks; add preventDefault on Enter; unify add/removeEventListener calls to new events.
ESC/cancel handling in editors
src/components/DateTimeEditor/DateTimeEditor.react.js, src/components/GeoPointEditor/GeoPointEditor.react.js, src/components/NumberEditor/NumberEditor.react.js, src/components/StringEditor/StringEditor.react.js
Add Escape (27) handling to cancel: call onCancel if provided, otherwise commit original/current value; prevent default and stop propagation; mirror logic across latitude/longitude in GeoPoint.
Prop surface changes
src/components/DateTimeEditor/DateTimeEditor.react.js
Add optional public prop onCancel.
Prop plumbing in Data Browser
src/dashboard/Data/Browser/Editor.react.js
Pass onCancel to String, DateTime, Number, GeoPoint, File, Array/Object/Polygon editors, including encoded JSON flows; no other logic changes.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor U as User
  participant E as Editor (e.g., String/Number/DateTime/GeoPoint)
  participant B as Browser.Editor (parent)

  rect rgba(230,240,255,0.4)
    note over U,E: Key handling on keydown
    U->>E: keydown Enter
    E->>E: validate/prepare value
    E-->>B: onCommit(value)
    E-->>U: preventDefault + stopPropagation
  end

  rect rgba(255,235,230,0.5)
    note over U,E: Cancel flow on Escape
    U->>E: keydown Escape
    alt onCancel provided
      E-->>B: onCancel()
    else
      E-->>B: onCommit(original/current value)
    end
    E-->>U: preventDefault + stopPropagation
  end

  rect rgba(235,255,235,0.5)
    note over U,E: External interaction
    U->>E: body touchend (outside)
    E->>E: checkExternalClick()
    alt commit or cancel per editor state
      E-->>B: onCommit(...) or onCancel()
    end
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The pull request description follows the checklist template by including checklist items, an issue description, and an approach section, but it omits the required “Closes: <issue_number>” line to reference a specific issue and lacks the “### TODOs before merging” section with test and documentation checkboxes. Please fill in the “Closes: <issue_number>” under the Issue Description section and add the “### TODOs before merging” section with checkboxes for adding tests and updating documentation to fully match the repository template.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The title clearly and concisely summarizes the primary change by fixing the ESC key behavior to cancel editing in the data browser cell. It directly relates to the core functionality modified in the pull request and is sufficiently specific for quick scanning.
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

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 307ec78 and b00ffef.

📒 Files selected for processing (5)
  • src/components/DateTimeEditor/DateTimeEditor.react.js (2 hunks)
  • src/components/GeoPointEditor/GeoPointEditor.react.js (3 hunks)
  • src/components/NumberEditor/NumberEditor.react.js (2 hunks)
  • src/components/StringEditor/StringEditor.react.js (2 hunks)
  • src/dashboard/Data/Browser/Editor.react.js (5 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/dashboard/Data/Browser/Editor.react.js (4)
src/components/DateTimeEditor/DateTimeEditor.react.js (1)
  • DateTimeEditor (13-140)
src/components/NumberEditor/NumberEditor.react.js (1)
  • NumberEditor (12-86)
src/components/GeoPointEditor/GeoPointEditor.react.js (1)
  • GeoPointEditor (13-183)
src/components/StringEditor/StringEditor.react.js (1)
  • StringEditor (11-98)
⏰ 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). (1)
  • GitHub Check: Docker linux/amd64
🔇 Additional comments (17)
src/components/StringEditor/StringEditor.react.js (2)

24-35: LGTM! Event listener setup and cleanup are correct.

The addition of touchend alongside click improves mobile support, and the switch from keypress to keydown aligns with modern best practices for keyboard event handling. The cleanup in componentWillUnmount correctly matches the setup.


43-62: LGTM! ESC key handling is correctly implemented.

The ESC key handling logic is sound:

  • Invokes onCancel if provided, otherwise commits the original value via onCommit(this.props.value)
  • preventDefault() and stopPropagation() prevent unwanted side effects
  • The Enter key now also calls preventDefault() to avoid default form submission behavior
src/components/GeoPointEditor/GeoPointEditor.react.js (3)

30-53: LGTM! Event listener management is correct.

The switch from keypress to keydown is properly implemented, and the cleanup in componentWillUnmount correctly mirrors the setup in componentDidMount.


72-87: LGTM! Latitude key handling is correctly implemented.

The ESC key handling follows the same pattern as other editors, and the preventDefault() call for Enter/comma keys prevents default browser behavior while maintaining focus navigation.


89-103: LGTM! Longitude key handling is correctly implemented.

The implementation mirrors handleKeyLatitude, ensuring consistent behavior across both input fields.

src/dashboard/Data/Browser/Editor.react.js (8)

21-32: LGTM! onCancel correctly propagated to StringEditor.


33-51: LGTM! onCancel correctly propagated to Array/Object StringEditor.


52-90: LGTM! onCancel correctly propagated to Polygon StringEditor.


91-104: LGTM! onCancel correctly propagated to Date editors.

Both the readonly StringEditor and the DateTimeEditor now receive the onCancel prop.


107-108: LGTM! onCancel correctly propagated to NumberEditor.


109-110: LGTM! onCancel correctly propagated to GeoPointEditor.


115-129: LGTM! onCancel correctly propagated to Pointer StringEditor.


113-114: No change needed for ACL cancellation
ACLEditor wires PermissionsDialog’s onCancel to onCommit(value), so ESC resets to the original ACL. Passing an external onCancel isn’t required.

Likely an incorrect or invalid review comment.

src/components/NumberEditor/NumberEditor.react.js (2)

25-36: LGTM! Event listener setup and cleanup are correct.

The implementation follows the same pattern as StringEditor, with proper setup and teardown of touchend and keydown listeners.


44-59: LGTM! Keyboard handling is correctly implemented.

The ESC key handling follows the established pattern across all editors, with proper fallback to committing the original value when onCancel is not provided.

src/components/DateTimeEditor/DateTimeEditor.react.js (2)

34-44: LGTM! Event listener setup and cleanup are correct.

The keydown listener is correctly attached to inputRef rather than body, which is appropriate for this component's popover-based date picker UI.


52-67: LGTM! Keyboard handling is correctly implemented.

The ESC key handling follows the same pattern as other editors, ensuring consistent behavior across the application.


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.

Copy link

uffizzi-cloud bot commented Oct 14, 2025

Uffizzi Ephemeral Environment deployment-65616

⌚ Updated Oct 14, 2025, 20:57 UTC

☁️ https://app.uffizzi.com/github.com/parse-community/parse-dashboard/pull/3001

📄 View Application Logs etc.

What is Uffizzi? Learn more

@mtrezza mtrezza merged commit d1d7241 into parse-community:alpha Oct 14, 2025
11 checks passed
@mtrezza mtrezza deleted the fix/esc-key branch October 14, 2025 21:37
parseplatformorg pushed a commit that referenced this pull request Oct 14, 2025
# [7.6.0-alpha.10](7.6.0-alpha.9...7.6.0-alpha.10) (2025-10-14)

### Bug Fixes

* ESC key does not cancel editing in data browser cell ([#3001](#3001)) ([d1d7241](d1d7241))
@parseplatformorg
Copy link
Contributor

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

@parseplatformorg parseplatformorg added the state:released-alpha Released as alpha version label Oct 14, 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