Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 [Bug]: DatetimePicker在Form中,onConfirm返回的value错误 #663

Closed
1 of 2 tasks
xiaolong233 opened this issue Jul 18, 2023 · 1 comment · Fixed by #694
Closed
1 of 2 tasks

🐛 [Bug]: DatetimePicker在Form中,onConfirm返回的value错误 #663

xiaolong233 opened this issue Jul 18, 2023 · 1 comment · Fixed by #694
Labels
🕵️‍♂️ bug Something isn't working

Comments

@xiaolong233
Copy link

xiaolong233 commented Jul 18, 2023

Which React Vant packages are impacted?

  • react-vant (React Vant core)
  • react-vant-icons(React Vant Icon)

What version of React Vant are you using?

3.3.1

Reproduce live demo(codesandebox or stackblitz)?

No response

Descripition

DatetimePicker组件在Form组件中,以Popup的方式被调用。此时,如果把Form.Itemtrigger设置为onoConfirm时,返回的value不是用户选择的日期。
通过监听DatetimePicker组件的onChangeonConfirm事件发现,如果不设置Form.Itemtrigger时,onConfirm返回的value是正确的,但如果设置为onoConfirm时,则返回的value时错误的。

const [form] = Form.useForm();
......
<Form form={form} onFieldsChange={(values) => console.log(values)}>
    <Form.Item 
            name="beginDate" 
            label="起保日期" 
            isLink 
            trigger="onConfirm" 
            onClick={(e, ref) => { 
                   ref?.current?.open(); 
            }}
    >
        <DatetimePicker 
                title="选择起保日期" 
                type="date" 
                popup 
                onChange={(value: Date) => console.log(value)} 
                onConfirm={(value: Date) => console.log(value)}
        >
                {(value: Date) => (value ? moment(value).format('yyyy-MM-DD') : '请选择起保日期')}
        </DatetimePicker>
    </Form.Item>
</Form>

效果图:
1
调试输出:
2

@3lang3 3lang3 added the 🕵️‍♂️ bug Something isn't working label Jul 26, 2023
@day-xue
Copy link
Contributor

day-xue commented Dec 16, 2023

感觉可以包一层 把传下来的onchange 事件在onConfirm 调用一次

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🕵️‍♂️ bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants