Skip to content

Commit

Permalink
fix(FormRender): DataRangePicker warning tips
Browse files Browse the repository at this point in the history
`disabled` should not set with empty `value`
  • Loading branch information
Barrior committed Oct 25, 2024
1 parent 0c65044 commit a85dab7
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions packages/form-render-react/src/renderers/DateRangePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,22 @@ const DateRangePicker: IProps = ({ schema, value, onChange, disabled, validator
return (
<DatePicker.RangePicker
allowClear
allowEmpty
style={{ width: '100%' }}
{...schema.renderOptions}
disabled={disabled}
status={validator.status as never}
value={value ? [dayjs(value[0]), dayjs(value[1])] : null}
onChange={(val) => {
if (val) {
if (val && val[0] && val[1]) {
// 不是 showTime 的情况,endTime 时分秒设置到当日结束时间
const startTime = showTime ? val[0] : val[0]?.startOf('day')
const endTime = showTime ? val[1] : val[1]?.endOf('day')
const startTime = showTime ? val[0] : val[0].startOf('day')
const endTime = showTime ? val[1] : val[1].endOf('day')
onChange([toISOString(startTime), toISOString(endTime)])
} else {
onChange(undefined)
}
}}
disabled={disabled}
/>
)
}
Expand Down

0 comments on commit a85dab7

Please sign in to comment.