Skip to content

Commit c690077

Browse files
committed
🐛 Fix: Prevent multiple clicks needed for selecting date
- Remove index files for DatePicker and Input components - Update import paths for DatePicker and Input - Modify Focusable component to use setIsFocused instead of toggleFocused - Adjust DatePicker input to use StyledInput
1 parent 2dc5fec commit c690077

File tree

7 files changed

+11
-15
lines changed

7 files changed

+11
-15
lines changed

packages/web/src/components/DatePicker/DatePicker.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import { isDark } from "@core/util/color.utils";
77
import { theme } from "@web/common/styles/theme";
88
import { Flex } from "@web/components/Flex";
99
import { AlignItems, JustifyContent } from "@web/components/Flex/styled";
10-
import { Input } from "@web/components/Input";
1110
import { Text } from "@web/components/Text";
11+
import { StyledInput } from "../Input/styled";
1212
import {
1313
ChangeDayButtonsStyledFlex,
1414
MonthContainerStyled,
@@ -79,7 +79,7 @@ export const DatePicker: React.FC<Props> = ({
7979
view={view}
8080
/>
8181
)}
82-
customInput={<Input bgColor={inputColor} onBlurCapture={onInputBlur} />}
82+
customInput={<StyledInput bgColor={inputColor} />}
8383
dateFormat={"M-d-yyyy"}
8484
formatWeekDay={(day) => day[0]}
8585
open={isOpen}

packages/web/src/components/DatePicker/index.ts

Lines changed: 0 additions & 3 deletions
This file was deleted.

packages/web/src/components/Focusable/Focusable.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export type Props<T extends ClassNamedComponent> = T &
1212
underlineColor?: string;
1313
};
1414

15-
const _Focusable = <T,>(
15+
const _Focusable = <T extends ClassNamedComponent>(
1616
{
1717
autoFocus = false,
1818
Component,
@@ -22,16 +22,18 @@ const _Focusable = <T,>(
2222
}: Props<T>,
2323
ref: Ref<HTMLDivElement>,
2424
) => {
25-
const [isFocused, toggleFocused] = useState(autoFocus);
25+
const [isFocused, setIsFocused] = useState(false);
2626
const rest = props as unknown as T;
2727

2828
return (
2929
<>
3030
<Component
3131
{...rest}
3232
ref={ref}
33-
onFocus={() => toggleFocused(true)}
34-
onBlur={() => toggleFocused(false)}
33+
onFocus={() => setIsFocused(true)}
34+
onBlur={() => {
35+
setIsFocused(false);
36+
}}
3537
autoFocus={autoFocus}
3638
/>
3739
{!!withUnderline && isFocused && <Divider color={underlineColor} />}

packages/web/src/components/Input/index.ts

Lines changed: 0 additions & 3 deletions
This file was deleted.

packages/web/src/views/Calendar/components/Sidebar/MonthTab/MonthPicker/SidebarMonthPicker.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import dayjs from "dayjs";
22
import weekPlugin from "dayjs/plugin/weekOfYear";
33
import React, { FC, useEffect, useState } from "react";
44
import { ID_DATEPICKER_SIDEBAR } from "@web/common/constants/web.constants";
5-
import { DatePicker } from "@web/components/DatePicker";
5+
import { DatePicker } from "@web/components/DatePicker/DatePicker";
66
import { WeekProps } from "@web/views/Calendar/hooks/useWeek";
77
import { MonthPickerContainer } from "./../styled";
88

packages/web/src/views/Forms/EventForm/DateTimeSection/DatePickers/DatePickers.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
dateIsValid,
88
shouldAdjustComplimentDate,
99
} from "@web/common/utils/web.date.util";
10-
import { DatePicker } from "@web/components/DatePicker";
10+
import { DatePicker } from "@web/components/DatePicker/DatePicker";
1111
import { AlignItems } from "@web/components/Flex/styled";
1212
import { StyledDateFlex } from "./styled";
1313

packages/web/src/views/Forms/EventForm/styled.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { ZIndex } from "@web/common/constants/web.constants";
33
import { hoverColorByPriority } from "@web/common/styles/theme.util";
44
import { PriorityButton } from "@web/components/Button/styled";
55
import { Flex } from "@web/components/Flex";
6-
import { Input } from "@web/components/Input";
6+
import { Input } from "@web/components/Input/Input";
77
import { Textarea } from "@web/components/Textarea";
88
import { EVENT_WIDTH_MINIMUM } from "@web/views/Calendar/layout.constants";
99
import { StyledFormProps } from "./types";

0 commit comments

Comments
 (0)