Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a clear/reset button in InternalDateInput to reset/unschedule events #3154

Merged
merged 11 commits into from
Dec 29, 2023
Merged
Prev Previous commit
Next Next commit
Moved clear context call from DateInput to DateFieldInput
  • Loading branch information
atharvParlikar committed Dec 29, 2023
commit 13931070a986e328d31a1409bbb76e7b3c7ca3b3
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ export type DateFieldInputProps = {
onEscape?: FieldInputEvent;
onTab?: FieldInputEvent;
onShiftTab?: FieldInputEvent;
clearable?: boolean;
};

export const DateFieldInput = ({
onEnter,
onEscape,
onClickOutside,
}: DateFieldInputProps) => {
const { fieldValue, hotkeyScope } = useDateTimeField();
const { fieldValue, hotkeyScope, clearable } = useDateTimeField();

const persistField = usePersistField();

Expand Down Expand Up @@ -57,6 +58,7 @@ export const DateFieldInput = ({
onEnter={handleEnter}
onEscape={handleEscape}
value={dateValue}
clearable={clearable}
/>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { useTheme } from '@emotion/react';
import styled from '@emotion/styled';
import { flip, offset, useFloating } from '@floating-ui/react';

import { useDateTimeField } from '@/object-record/field/meta-types/hooks/useDateTimeField';
import { DateDisplay } from '@/ui/field/display/components/DateDisplay';
import { InternalDatePicker } from '@/ui/input/components/internal/date/components/InternalDatePicker';
import { Nullable } from '~/types/Nullable';
Expand Down Expand Up @@ -38,6 +37,7 @@ export type DateInputProps = {
newDate: Nullable<Date>,
) => void;
hotkeyScope: string;
clearable?: boolean;
};

export const DateInput = ({
Expand All @@ -46,6 +46,7 @@ export const DateInput = ({
onEnter,
onEscape,
onClickOutside,
clearable,
}: DateInputProps) => {
const theme = useTheme();

Expand Down Expand Up @@ -80,8 +81,6 @@ export const DateInput = ({
hotkeyScope,
});

const { clearable } = useDateTimeField();

return (
<div ref={wrapperRef}>
<div ref={refs.setReference}>
Expand Down