Skip to content

fix: Date value cannot be pasted into date field in data browser#3243

Merged
mtrezza merged 4 commits intoparse-community:alphafrom
mtrezza:fix/date-cell-paste
Mar 1, 2026
Merged

fix: Date value cannot be pasted into date field in data browser#3243
mtrezza merged 4 commits intoparse-community:alphafrom
mtrezza:fix/date-cell-paste

Conversation

@mtrezza
Copy link
Member

@mtrezza mtrezza commented Mar 1, 2026

Pull Request

Issue

Date value cannot be pasted into date field in data browser.

Tasks

  • Add tests
  • Add changes to documentation (guides, repository pages, in-code descriptions)

Summary by CodeRabbit

  • Bug Fixes

    • Improved timezone handling so inputs with explicit timezone indicators are respected and local times are correctly converted to UTC, preventing misinterpreted timestamps.
    • Prevented unexpected input resets by stopping automatic state overrides from incoming prop changes.
  • Refactor

    • Simplified internal UTC date formatting for more consistent, zero-padded display across the app.

@parse-github-assistant
Copy link

🚀 Thanks for opening this pull request!

@parseplatformorg
Copy link
Contributor

parseplatformorg commented Mar 1, 2026

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.

@coderabbitai
Copy link

coderabbitai bot commented Mar 1, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 605c765 and d7c7eec.

📒 Files selected for processing (1)
  • src/lib/DateUtils.js

📝 Walkthrough

Walkthrough

Removed automatic prop-to-state sync in DateTimeEditor and changed commitDate timezone handling to treat inputs ending with 'Z' or 'UTC' as explicit timezones (use parsed value) and treat other inputs as local time (convert to UTC). Replaced manual UTC string assembly with locale-based formatting in dateStringUTC.

Changes

Cohort / File(s) Summary
DateTimeEditor Timezone Handling
src/components/DateTimeEditor/DateTimeEditor.react.js
Removed componentWillReceiveProps. Updated commitDate to detect inputs ending with Z or UTC and set value from parsed date; otherwise interpret input as local time and convert to UTC before setting value. Added clarifying comments.
DateUtils UTC Formatting
src/lib/DateUtils.js
Replaced handcrafted UTC string assembly with date.toLocaleDateString('en-GB', ...) using explicit options (year, month, day, hour, minute, second, hour12: false, timeZone: 'UTC', timeZoneName: 'short') to produce the UTC-formatted string.

Sequence Diagram(s)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive The description is missing the required 'Approach' section that should describe the changes made in the PR to fix the issue. Add an 'Approach' section explaining the specific changes made to fix the date pasting issue (timezone handling, lifecycle method removal, etc.).
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main fix: addressing an issue where date values cannot be pasted into the date field in the data browser.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 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.

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.

🧹 Nitpick comments (2)
src/components/DateTimeEditor/DateTimeEditor.react.js (1)

84-101: Timezone detection may miss common formats.

The fix correctly handles the paste scenario for local time inputs, but the timezone detection is limited:

  1. Only checks for 'Z' and 'UTC' suffixes, missing other common formats like '+00:00', '+0000', 'GMT', or offset timezones like '+05:30'.
  2. The check is case-sensitive—'utc' or 'Utc' would be treated as local time.

For example, pasting 2024-03-01T10:00:00+05:30 would incorrectly be treated as local time and double-converted.

Consider a more robust timezone detection:

♻️ Suggested improvement for timezone detection
     } else {
-      if (this.state.text.endsWith('Z') || this.state.text.endsWith('UTC')) {
+      // Check for explicit timezone indicators (Z, UTC, GMT, or numeric offsets like +00:00, -0530)
+      const hasExplicitTimezone = /(?:Z|UTC|GMT|[+-]\d{2}:?\d{2})$/i.test(this.state.text.trim());
+      if (hasExplicitTimezone) {
         // Timezone is explicit; the parsed Date is already correct.
         this.setState({ value: date });
       } else {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/components/DateTimeEditor/DateTimeEditor.react.js` around lines 84 - 101,
The timezone detection that checks this.state.text.endsWith('Z') or 'UTC' is too
narrow and case-sensitive; update the check in DateTimeEditor to use a
case-insensitive regex against this.state.text (trimmed) that matches common
timezone suffixes such as Z, UTC, GMT and numeric offsets like +05:30 or +0530
(e.g. /(?:Z|UTC|GMT|[+-]\d{2}:?\d{2})$/i). If the regex matches treat the parsed
Date as already correct and call this.setState({ value: date }) as before;
otherwise keep the existing local-to-UTC conversion that creates utc via
Date.UTC(...) and then call this.setState({ value: utc }). Ensure you reference
this.state.text for matching and preserve the existing Date.UTC conversion logic
and this.setState calls.
src/lib/DateUtils.js (1)

105-117: Consider using toLocaleString instead of toLocaleDateString for semantic clarity.

The refactored function is cleaner and works correctly for all callers. However, toLocaleString is more semantically appropriate for datetime formatting, since toLocaleDateString is conventionally for date-only values. While toLocaleDateString with time options works in practice, switching to toLocaleString would make the intent clearer:

export function dateStringUTC(date) {
  return date.toLocaleString('en-GB', {
    year: 'numeric',
    month: 'short',
    day: 'numeric',
    hour: 'numeric',
    minute: 'numeric',
    second: 'numeric',
    hour12: false,
    timeZone: 'UTC',
    timeZoneName: 'short',
  });
}

All current usages display the result in the UI and don't depend on a specific format, so this change is safe.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/lib/DateUtils.js` around lines 105 - 117, Replace the use of
Date.prototype.toLocaleDateString with toLocaleString in the dateStringUTC
function: change the call inside export function dateStringUTC(date) from
date.toLocaleDateString(...) to date.toLocaleString(...) while keeping the same
locale ('en-GB') and options (year, month, day, hour, minute, second, hour12:
false, timeZone: 'UTC', timeZoneName: 'short') so the function semantics match
datetime formatting.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/components/DateTimeEditor/DateTimeEditor.react.js`:
- Around line 84-101: The timezone detection that checks
this.state.text.endsWith('Z') or 'UTC' is too narrow and case-sensitive; update
the check in DateTimeEditor to use a case-insensitive regex against
this.state.text (trimmed) that matches common timezone suffixes such as Z, UTC,
GMT and numeric offsets like +05:30 or +0530 (e.g.
/(?:Z|UTC|GMT|[+-]\d{2}:?\d{2})$/i). If the regex matches treat the parsed Date
as already correct and call this.setState({ value: date }) as before; otherwise
keep the existing local-to-UTC conversion that creates utc via Date.UTC(...) and
then call this.setState({ value: utc }). Ensure you reference this.state.text
for matching and preserve the existing Date.UTC conversion logic and
this.setState calls.

In `@src/lib/DateUtils.js`:
- Around line 105-117: Replace the use of Date.prototype.toLocaleDateString with
toLocaleString in the dateStringUTC function: change the call inside export
function dateStringUTC(date) from date.toLocaleDateString(...) to
date.toLocaleString(...) while keeping the same locale ('en-GB') and options
(year, month, day, hour, minute, second, hour12: false, timeZone: 'UTC',
timeZoneName: 'short') so the function semantics match datetime formatting.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0cd2471 and 605c765.

📒 Files selected for processing (2)
  • src/components/DateTimeEditor/DateTimeEditor.react.js
  • src/lib/DateUtils.js

coderabbitai[bot]
coderabbitai bot previously approved these changes Mar 1, 2026
@mtrezza mtrezza merged commit e902bea into parse-community:alpha Mar 1, 2026
1 of 2 checks passed
parseplatformorg pushed a commit that referenced this pull request Mar 1, 2026
# [9.1.0-alpha.3](9.1.0-alpha.2...9.1.0-alpha.3) (2026-03-01)

### Bug Fixes

* Date value cannot be pasted into date field in data browser ([#3243](#3243)) ([e902bea](e902bea))
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 9.1.0-alpha.3

@parseplatformorg parseplatformorg added the state:released-alpha Released as alpha version label Mar 1, 2026
@mtrezza mtrezza deleted the fix/date-cell-paste branch March 1, 2026 17:50
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