[PR #25522] fix(date-picker): handle string date to avoid crash #31102

Closed
opened 2026-02-21 20:48:49 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langgenius/dify/pull/25522

State: closed
Merged: Yes


Important

  1. Make sure you have read our contribution guidelines
  2. Ensure there is an associated issue and you have been assigned to it
  3. Use the correct syntax to link this PR: Fixes #25507 .

fix https://github.com/langgenius/dify/issues/25507

Summary


This PR fixes an issue where the date-picker component crashes when receiving a date string from a native HTML <input type="date"/>.
Previously, the DatePicker expected a Day.js object, but the template transformation node passed a plain string, causing a client-side exception and breaking the application.

Related error:
Application error: a client-side exception has occurred while loading localhost (see the browser console for more information).


Root Cause

The date-picker relied on Day.js objects for parsing/formatting dates. Native HTML date inputs produce string values (e.g., "2025-09-11"), which were directly passed without conversion.
This mismatch led to the DatePicker throwing an error at runtime.


Fix

  • Detect string values from native date inputs
  • Convert them to Day.js objects before passing into the component
  • Ensured compatibility with the existing format handling
  • Guarantee that any date value input (string, Date object, or Day.js) will never cause a client-side crash
    

Screenshots

Before After
before after

Checklist

  • I understand that this PR may be closed in case there was no previous discussion or Issues.
  • I've added tests for the introduced change and ensured atomic commits.
  • I've updated the documentation where necessary.
  • Code formatting and lint checks have been run successfully.
**Original Pull Request:** https://github.com/langgenius/dify/pull/25522 **State:** closed **Merged:** Yes --- > [!IMPORTANT] > > 1. Make sure you have read our [contribution guidelines](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md) > 1. Ensure there is an associated issue and you have been assigned to it > 1. Use the correct syntax to link this PR: `Fixes #25507 `. fix https://github.com/langgenius/dify/issues/25507 ## Summary  This PR fixes an issue where the `date-picker` component crashes when receiving a date string from a native HTML `<input type="date"/>`. Previously, the `DatePicker` expected a Day.js object, but the template transformation node passed a plain string, causing a client-side exception and breaking the application.  **Related error:** Application error: a client-side exception has occurred while loading localhost (see the browser console for more information).  ### Root Cause The `date-picker` relied on Day.js objects for parsing/formatting dates. Native HTML date inputs produce string values (e.g., `"2025-09-11"`), which were directly passed without conversion. This mismatch led to the `DatePicker` throwing an error at runtime.  ### Fix - Detect string values from native date inputs - Convert them to Day.js objects before passing into the component - Ensured compatibility with the existing format handling - Guarantee that any `date` value input (string, Date object, or Day.js) will **never cause a client-side crash**  ## Screenshots | Before | After | |--------|-------| | ![before](https://github.com/user-attachments/assets/d06a0f05-0a2c-4e6e-9b24-2e61524f2dd1) | ![after](https://github.com/user-attachments/assets/4b567782-f9d6-4cc9-93a9-3570fb5283a2) | ## Checklist - I understand that this PR may be closed in case there was no previous discussion or Issues. - I've added tests for the introduced change and ensured atomic commits. - I've updated the documentation where necessary. - Code formatting and lint checks have been run successfully.
yindo added the pull-request label 2026-02-21 20:48:49 -05:00
yindo closed this issue 2026-02-21 20:48:50 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#31102