Skip to content

Commit

Permalink
remove comments and add a DateRange story in InputGroup
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorvnoj committed Feb 25, 2025
1 parent d812a93 commit 8da1e03
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
29 changes: 28 additions & 1 deletion docs/components/InputGroup/Web.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React from "react";
import React, { useState } from "react";
import { ComponentMeta, ComponentStory } from "@storybook/react";
import { InputGroup } from "@jobber/components/InputGroup";
import { InputTime } from "@jobber/components/InputTime";
import { InputText } from "@jobber/components/InputText";
import { InputDate } from "@jobber/components/InputDate";

export default {
title: "Components/Forms and Inputs/InputGroup/Web",
Expand Down Expand Up @@ -49,6 +50,27 @@ const NestedTemplate: ComponentStory<typeof InputGroup> = args => {
);
};

const DateRangeTemplate: ComponentStory<typeof InputGroup> = args => {
const [startDate, setStartDate] = useState(new Date("2024-01-01"));
const [endDate, setEndDate] = useState(new Date("2024-12-31"));

return (
<InputGroup {...args}>
<InputDate
value={startDate}
onChange={setStartDate}
placeholder="Start Date"
/>
<InputDate
value={endDate}
onChange={setEndDate}
placeholder="End Date"
minDate={startDate}
/>
</InputGroup>
);
};

export const Basic = BasicTemplate.bind({});
Basic.args = {
flowDirection: "vertical",
Expand All @@ -58,3 +80,8 @@ export const Nested = NestedTemplate.bind({});
Nested.args = {
flowDirection: "vertical",
};

export const DateRange = DateRangeTemplate.bind({});
DateRange.args = {
flowDirection: "horizontal",
};
3 changes: 0 additions & 3 deletions packages/components/src/DatePicker/DatePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,21 +172,18 @@ export function DatePicker({
}

function handleCalendarOpen() {
// If there's already an open picker that's different from this one, close it
if (
openDatePickerRef.current &&
openDatePickerRef.current !== pickerRef.current
) {
openDatePickerRef.current.setOpen(false);
}

// Set this picker as the currently open one
openDatePickerRef.current = pickerRef.current;
setOpen(true);
}

function handleCalendarClose() {
// Clear the ref if this picker is the one that's closing
if (openDatePickerRef.current === pickerRef.current) {
openDatePickerRef.current = null;
}
Expand Down

0 comments on commit 8da1e03

Please sign in to comment.