Skip to content

Timepicker开启needConfirm=false,showTime=true并设置presets,点击presets不能直接关闭面板还需要点击空白处 #54436

@houzhiyang1997

Description

@houzhiyang1997

Reproduction link

Edit on StackBlitz

Steps to reproduce

`import React, { useState } from 'react';
import './index.css';
import type { TimeRangePickerProps } from 'antd';
import { DatePicker, Space } from 'antd';
import dayjs from 'dayjs';
import type { Dayjs } from 'dayjs';

const { RangePicker } = DatePicker;

const onRangeChange = (
dates: null | (Dayjs | null)[],
dateStrings: string[]
) => {
if (dates) {
console.log('From: ', dates[0], ', to: ', dates[1]);
console.log('From: ', dateStrings[0], ', to: ', dateStrings[1]);
} else {
console.log('Clear');
}
};

const rangePresets: TimeRangePickerProps['presets'] = [
{ label: 'Last 7 Days', value: [dayjs().add(-7, 'd'), dayjs()] },
{ label: 'Last 14 Days', value: [dayjs().add(-14, 'd'), dayjs()] },
{ label: 'Last 30 Days', value: [dayjs().add(-30, 'd'), dayjs()] },
{ label: 'Last 90 Days', value: [dayjs().add(-90, 'd'), dayjs()] },
];

const App: React.FC = () => {
return (



);
};

export default App;`

What is expected?

点击预设值可以直接setValue并关闭面板

What is actually happening?

需要点击两次

Environment Info
antd 5.26.6
React 18.2.0
System windows 11
Browser Chorme 120

Metadata

Metadata

Assignees

No one assigned

    Labels

    🐛 BugAnt Design Team had proved that this is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions