Skip to content

Commit

Permalink
Fixed TimePicker value and Min Max Date rules
Browse files Browse the repository at this point in the history
  • Loading branch information
snturk committed Feb 26, 2024
1 parent 2c97436 commit 1060800
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,20 @@ export function WithSeconds() {
);
}

export function MinDate() {
export function MinMaxDate() {
const minDate = new Date();
minDate.setHours(0, 30, 0, 0);

const maxDate = new Date();
maxDate.setDate(maxDate.getDate() + 5);
maxDate.setHours(22, 30, 0, 0);

return (
<div style={{ padding: 40, maxWidth: 400 }}>
<div style={{ marginBottom: 20 }}>
<div>Min date: {minDate.toLocaleString()}</div>
<div>Max date: {maxDate.toLocaleString()}</div>
</div>
<DateTimePicker
placeholder="Date time picker"
withSeconds
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const TimeInput = factory<TimeInputFactory>((_props, ref) => {
});

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

if (val) {
Expand Down Expand Up @@ -108,6 +108,7 @@ export const TimeInput = factory<TimeInputFactory>((_props, ref) => {
styles={resolvedStyles}
unstyled={unstyled}
ref={ref}
value={value}
{...others}
step={withSeconds ? 1 : 60}
onChange={onTimeChange}
Expand Down

0 comments on commit 1060800

Please sign in to comment.