react-component / react-component/picker

Trigger onOpenChange shouldn't sync with onChange take effect.

Open
#406 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
304
Forks
345
Avg merge
2d 7h
Merged PRs (30d)
7

Description

demo:

const handleOpenChange =(visible: boolean) => {
    if (visible) {
       return
    }
   // get an old value
    console.log('handleOpenChange', visible, dateRange)
    //...
  }

  const handlePickerChange = ({ start, end }: { start: number, end: number}) => {
    // setState
    setDateRange({ startAt: dayjs(start).unix(), endAt: dayjs(end).unix() })
  }

  const pickerValue = isValidDateRange
    ? { start: dateRange.startAt! * 1000, end: dateRange.endAt! * 1000 }
    : { start: null, end: null }


return (
   <RcRangePick ... />
)

https://github.com/react-component/picker/blob/5306c8938aded49c5d6f6b6d4761ddab25e3cce9/src/RangePicker.tsx#L775-L778

according to the source code above, I think the trigger onOpenChange shouldn't sync with onChange take effect. otherwise, a
lways get an old value in onOpenChange.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at src/RangePicker.tsx lines 775-778 and reproduce the supplied controlled-range example. Trace the ordering of onOpenChange and onChange, then verify that onOpenChange no longer observes the previous range value when the picker changes; the payload does not name a test file.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.