Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

CDateRangePicker doesn't trigger onChange callbacks when date parsing fails, breaking form validation #441

Open
@DerekChan65535

Description

@DerekChan65535

Description

TheCDateRangePicker component has a critical issue whereonStartDateChange andonEndDateChange callbacks arenot triggered when date parsing fails. This breaks form validation workflows and prevents proper integration with form libraries likereact-hook-form.


Current Behavior

In thehandleOnChange function (lines 446-460), whengetLocalDateFromString returnsundefined for invalid input, the conditiondate instanceof Date && date.getTime() fails andno callbacks are triggered:

consthandleOnChange=useDebouncedCallback((value:string,input:string)=>{constdate=inputDateParse    ?inputDateParse(value)    :getLocalDateFromString(value,locale,timepicker)if(dateinstanceofDate&&date.getTime()){// Only calls callbacks on successful parsingsetCalendarDate(date)if(input==='start'){setStartDate(date)onStartDateChange?.(date)}else{setEndDate(date)onEndDateChange?.(date)}}// BUG: No callbacks triggered when parsing fails},inputOnChangeDelay)

Problems This Causes

  1. Form Validation Broken: Parent components cannot detect when user enters invalid dates
  2. Inconsistent State: Component holds last valid date while input shows invalid text
  3. Clearing Issues: Parent components aren't notified when fields are cleared
  4. Integration Issues: Breaks compatibility with form validation libraries

Expected Behavior

When date parsing fails or input is cleared, the component should still triggeronStartDateChange/onEndDateChangewith null values, consistent with how standard form inputs behave.


Reproduction Steps

  1. Create aCDateRangePicker with validation
  2. Type invalid date format (e.g.,"abc" or incomplete date)
  3. Observe thatonChange callback is never triggered
  4. Form validation cannot detect the invalid state

Proposed Fix

Modify thehandleOnChange function totrigger callbacks with null when parsing fails:

consthandleOnChange=useDebouncedCallback((value:string,input:string)=>{constdate=inputDateParse    ?inputDateParse(value)    :getLocalDateFromString(value,locale,timepicker)if(dateinstanceofDate&&date.getTime()){setCalendarDate(date)if(input==='start'){setStartDate(date)onStartDateChange?.(date)}else{setEndDate(date)onEndDateChange?.(date)}}else{// NEW: Handle parsing failures by calling callbacks with nullif(input==='start'){setStartDate(null)onStartDateChange?.(null)}else{setEndDate(null)onEndDateChange?.(null)}}},inputOnChangeDelay)

Impact

This change wouldalignCDateRangePicker with standard form input behavior and enable proper validation workflows without breaking existing functionality.


Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp