Fix date picker wrong on certain timezones (#5972)
Timezone with a negative offset weren't working good with date pickers. I split the logic for display and parsing between date only and datetime. Date time is sending and displaying using timezone, and date only is sending and displaying by forcing the date to take its UTC day and month and 00:00:00 time. This way its consistent across all timezones.
This commit is contained in:
@ -121,6 +121,7 @@ export const FieldInput = ({
|
||||
onEscape={onEscape}
|
||||
onClickOutside={onClickOutside}
|
||||
onClear={onSubmit}
|
||||
onSubmit={onSubmit}
|
||||
/>
|
||||
) : isFieldDate(fieldDefinition) ? (
|
||||
<DateFieldInput
|
||||
@ -128,6 +129,7 @@ export const FieldInput = ({
|
||||
onEscape={onEscape}
|
||||
onClickOutside={onClickOutside}
|
||||
onClear={onSubmit}
|
||||
onSubmit={onSubmit}
|
||||
/>
|
||||
) : isFieldNumber(fieldDefinition) ? (
|
||||
<NumberFieldInput
|
||||
|
||||
@ -13,6 +13,7 @@ export type DateFieldInputProps = {
|
||||
onEnter?: FieldInputEvent;
|
||||
onEscape?: FieldInputEvent;
|
||||
onClear?: FieldInputEvent;
|
||||
onSubmit?: FieldInputEvent;
|
||||
};
|
||||
|
||||
export const DateFieldInput = ({
|
||||
@ -20,6 +21,7 @@ export const DateFieldInput = ({
|
||||
onEscape,
|
||||
onClickOutside,
|
||||
onClear,
|
||||
onSubmit,
|
||||
}: DateFieldInputProps) => {
|
||||
const { fieldValue, setDraftValue } = useDateField();
|
||||
|
||||
@ -39,6 +41,10 @@ export const DateFieldInput = ({
|
||||
onEnter?.(() => persistDate(newDate));
|
||||
};
|
||||
|
||||
const handleSubmit = (newDate: Nullable<Date>) => {
|
||||
onSubmit?.(() => persistDate(newDate));
|
||||
};
|
||||
|
||||
const handleEscape = (newDate: Nullable<Date>) => {
|
||||
onEscape?.(() => persistDate(newDate));
|
||||
};
|
||||
@ -69,6 +75,7 @@ export const DateFieldInput = ({
|
||||
clearable
|
||||
onChange={handleChange}
|
||||
onClear={handleClear}
|
||||
onSubmit={handleSubmit}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
@ -12,6 +12,7 @@ export type DateTimeFieldInputProps = {
|
||||
onEnter?: FieldInputEvent;
|
||||
onEscape?: FieldInputEvent;
|
||||
onClear?: FieldInputEvent;
|
||||
onSubmit?: FieldInputEvent;
|
||||
};
|
||||
|
||||
export const DateTimeFieldInput = ({
|
||||
@ -19,6 +20,7 @@ export const DateTimeFieldInput = ({
|
||||
onEscape,
|
||||
onClickOutside,
|
||||
onClear,
|
||||
onSubmit,
|
||||
}: DateTimeFieldInputProps) => {
|
||||
const { fieldValue, setDraftValue } = useDateTimeField();
|
||||
|
||||
@ -57,6 +59,10 @@ export const DateTimeFieldInput = ({
|
||||
onClear?.(() => persistDate(null));
|
||||
};
|
||||
|
||||
const handleSubmit = (newDate: Nullable<Date>) => {
|
||||
onSubmit?.(() => persistDate(newDate));
|
||||
};
|
||||
|
||||
const dateValue = fieldValue ? new Date(fieldValue) : null;
|
||||
|
||||
return (
|
||||
@ -69,6 +75,7 @@ export const DateTimeFieldInput = ({
|
||||
onChange={handleChange}
|
||||
isDateTimeInput
|
||||
onClear={handleClear}
|
||||
onSubmit={handleSubmit}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
@ -142,10 +142,9 @@ export const RecordTableCellContainer = ({
|
||||
[styles.cellBaseContainerSoftFocus]: hasSoftFocus,
|
||||
})}
|
||||
>
|
||||
{isInEditMode && (
|
||||
{isInEditMode ? (
|
||||
<RecordTableCellEditMode>{editModeContent}</RecordTableCellEditMode>
|
||||
)}
|
||||
{hasSoftFocus ? (
|
||||
) : hasSoftFocus ? (
|
||||
<RecordTableCellSoftFocusMode
|
||||
editModeContent={editModeContent}
|
||||
nonEditModeContent={nonEditModeContent}
|
||||
|
||||
Reference in New Issue
Block a user