Skip to content

Commit 1060800

Browse files
committed
Fixed TimePicker value and Min Max Date rules
1 parent 2c97436 commit 1060800

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

packages/@mantine/dates/src/components/DateTimePicker/DateTimePicker.story.tsx

+6-1
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,20 @@ export function WithSeconds() {
4040
);
4141
}
4242

43-
export function MinDate() {
43+
export function MinMaxDate() {
4444
const minDate = new Date();
4545
minDate.setHours(0, 30, 0, 0);
4646

4747
const maxDate = new Date();
4848
maxDate.setDate(maxDate.getDate() + 5);
4949
maxDate.setHours(22, 30, 0, 0);
50+
5051
return (
5152
<div style={{ padding: 40, maxWidth: 400 }}>
53+
<div style={{ marginBottom: 20 }}>
54+
<div>Min date: {minDate.toLocaleString()}</div>
55+
<div>Max date: {maxDate.toLocaleString()}</div>
56+
</div>
5257
<DateTimePicker
5358
placeholder="Date time picker"
5459
withSeconds

packages/@mantine/dates/src/components/TimeInput/TimeInput.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export const TimeInput = factory<TimeInputFactory>((_props, ref) => {
5959
});
6060

6161
const onTimeChange = (event: React.ChangeEvent<HTMLInputElement>) => {
62-
if (minTime !== undefined && maxTime !== undefined) {
62+
if (minTime !== undefined || maxTime !== undefined) {
6363
const val = event.currentTarget.value;
6464

6565
if (val) {
@@ -108,6 +108,7 @@ export const TimeInput = factory<TimeInputFactory>((_props, ref) => {
108108
styles={resolvedStyles}
109109
unstyled={unstyled}
110110
ref={ref}
111+
value={value}
111112
{...others}
112113
step={withSeconds ? 1 : 60}
113114
onChange={onTimeChange}

0 commit comments

Comments
 (0)