Closed manuel-rw closed 8 months ago
@rtivital I would like to work on this issue.
@rajeevdodda You are welcome to submit a PR with a fix
The codesandbox link is not found (https://codesandbox.io/s/twilight-darkness-pkdmwq?file=/src/App.tsx)
@manuel-rw are you able to provide a new replication. I would like to look into this issue.
What I understand about the problem from my own experience trying out the component.
Example:
const minDateTime = new Date('2024-01-01T01:00:00.000Z');
const maxDateTime = new Date('2024-01-02T01:00:00.000Z');
<DateTimePicker
placeholder="Date time picker"
clearable
minDate={minDateTime} // This is 01 Jan 2024, 9:00 AM on my local time (GMT+8)
maxDate={maxDateTime} // This is 02 Jan 2024, 9:00 AM on my local time (GMT+8)
/>
Expectations:
Actual behaviour:
The <TimeInput />
component uses the native html input tag with type="time"
.
As I understand from MDN docs:
min
and max
values for time inputs but it only triggers time validation when the user tries to submit the formUsing <datalist>
to provide suggestions
On Arc Browser:
function Demo() {
const ref = React.useRef<HTMLInputElement>(null);
const pickerControl = (
<ActionIcon variant="subtle" color="gray" onClick={() => ref.current?.showPicker()}>
<IconClock style={{ width: rem(16), height: rem(16) }} stroke={1.5} />
</ActionIcon>
);
return (
<>
<TimeInput
list="time"
label="Click icon to show browser picker"
ref={ref}
rightSection={pickerControl}
/>
<datalist id="time">
<option value="09:00">09:00</option>
<option value="10:00">10:00</option>
<option value="11:00">11:00</option>
<option value="12:00">12:00</option>
</datalist>
</>
);
}
Possible solution:
I'm currently developing a solution to that issue. Will push a PR soon.
What package has an issue
@mantine/dates
Describe the bug
DateTimePicker does not respect
minDate
andmaxDate
for the TimeInput component. You can select a time outside the allowed range.What version of @mantine/hooks page do you have in package.json?
6.0.8
If possible, please include a link to a codesandbox with the reproduced problem
https://codesandbox.io/s/twilight-darkness-pkdmwq?file=/src/App.tsx
Do you know how to fix the issue
Yes
Are you willing to participate in fixing this issue and create a pull request with the fix
No
Possible fix