Skip to content

Commit

Permalink
revert: go back to previous version with untouched DateInput component
Browse files Browse the repository at this point in the history
  • Loading branch information
Devessier committed Dec 16, 2024
1 parent 246a4fb commit 2d707ea
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ import { useDateField } from '@/object-record/record-field/meta-types/hooks/useD
import { DateInput } from '@/ui/field/input/components/DateInput';
import { isDefined } from '~/utils/isDefined';

import { useRef, useState } from 'react';
import { usePersistField } from '../../../hooks/usePersistField';
import { FieldInputClickOutsideEvent } from '@/object-record/record-field/meta-types/input/components/DateTimeFieldInput';
import { usePersistField } from '../../../hooks/usePersistField';

type FieldInputEvent = (persist: () => void) => void;

Expand Down Expand Up @@ -68,25 +67,16 @@ export const DateFieldInput = ({

const dateValue = fieldValue ? new Date(fieldValue) : null;

const wrapperRef = useRef<HTMLDivElement>(null);

const [temporaryValue, setTemporaryValue] =
useState<Nullable<Date>>(dateValue);

return (
<div ref={wrapperRef}>
<DateInput
onClickOutside={handleClickOutside}
onEnter={handleEnter}
onEscape={handleEscape}
clearable
onChange={handleChange}
onClear={handleClear}
onSubmit={handleSubmit}
wrapperRef={wrapperRef}
temporaryValue={temporaryValue}
setTemporaryValue={setTemporaryValue}
/>
</div>
<DateInput
onClickOutside={handleClickOutside}
onEnter={handleEnter}
onEscape={handleEscape}
value={dateValue}
clearable
onChange={handleChange}
onClear={handleClear}
onSubmit={handleSubmit}
/>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Nullable } from 'twenty-ui';

import { DateInput } from '@/ui/field/input/components/DateInput';

import { useRef, useState } from 'react';
import { usePersistField } from '../../../hooks/usePersistField';
import { useDateTimeField } from '../../hooks/useDateTimeField';

Expand Down Expand Up @@ -70,26 +69,17 @@ export const DateTimeFieldInput = ({

const dateValue = fieldValue ? new Date(fieldValue) : null;

const wrapperRef = useRef<HTMLDivElement>(null);

const [temporaryValue, setTemporaryValue] =
useState<Nullable<Date>>(dateValue);

return (
<div ref={wrapperRef}>
<DateInput
onClickOutside={handleClickOutside}
onEnter={handleEnter}
onEscape={handleEscape}
clearable
onChange={handleChange}
isDateTimeInput
onClear={handleClear}
onSubmit={handleSubmit}
wrapperRef={wrapperRef}
temporaryValue={temporaryValue}
setTemporaryValue={setTemporaryValue}
/>
</div>
<DateInput
onClickOutside={handleClickOutside}
onEnter={handleEnter}
onEscape={handleEscape}
value={dateValue}
clearable
onChange={handleChange}
isDateTimeInput
onClear={handleClear}
onSubmit={handleSubmit}
/>
);
};

0 comments on commit 2d707ea

Please sign in to comment.