Skip to content

Commit

Permalink
keep focus state when calendar is open
Browse files Browse the repository at this point in the history
  • Loading branch information
veej committed Aug 30, 2023
1 parent b20ffa9 commit 8a4958b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
6 changes: 3 additions & 3 deletions packages/bento-design-system/src/DateField/DateField.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ export const dateFieldRecipe = strictRecipe({
invalid: {},
notSet: {},
},
isFocused: {
isCalendarOpen: {
true: {},
},
},
compoundVariants: [
{
variants: {
validation: "valid",
isFocused: true,
isCalendarOpen: true,
},
style: bentoSprinkles({
boxShadow: { default: "outlineInputFocus", hover: "outlineInputFocus" },
Expand All @@ -52,7 +52,7 @@ export const dateFieldRecipe = strictRecipe({
{
variants: {
validation: "invalid",
isFocused: true,
isCalendarOpen: true,
},
style: bentoSprinkles({
boxShadow: { default: "outlineNegativeStrong", hover: "outlineNegativeStrong" },
Expand Down
9 changes: 8 additions & 1 deletion packages/bento-design-system/src/DateField/DateField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,13 @@ function SingleDateField({ disabled, readOnly, ...props }: Extract<Props, { type
errorMessageProps={errorMessageProps}
>
<Box {...groupProps} ref={ref}>
<Input type="single" fieldProps={fieldProps} buttonProps={buttonProps} ref={ref} />
<Input
type="single"
fieldProps={fieldProps}
buttonProps={buttonProps}
ref={ref}
isCalendarOpen={state.isOpen}
/>
</Box>
{state.isOpen && (
<Calendar
Expand Down Expand Up @@ -160,6 +166,7 @@ function RangeDateField({ disabled, readOnly, ...props }: Extract<Props, { type:
fieldProps={{ start: startFieldProps, end: endFieldProps }}
buttonProps={buttonProps}
ref={ref}
isCalendarOpen={state.isOpen}
/>
</Box>
{state.isOpen && (
Expand Down
3 changes: 2 additions & 1 deletion packages/bento-design-system/src/DateField/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type Props = (
}
) & {
buttonProps: AriaButtonProps<"button">;
isCalendarOpen: boolean;
ref: RefObject<HTMLInputElement>;
};

Expand Down Expand Up @@ -124,7 +125,7 @@ export function Input(props: Props) {
size: config.fontSize,
ellipsis: false,
}),
dateFieldRecipe({ validation: validationState }),
dateFieldRecipe({ validation: validationState, isCalendarOpen: props.isCalendarOpen }),
{
readOnly: isReadOnly,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export const DisabledDates = {
};
export const CalendarOpen = {
args: {
value: today,
value: new CalendarDate(2022, 2, 4),
},
play: async () => {
const button = screen.getByRole("button");
Expand Down

0 comments on commit 8a4958b

Please sign in to comment.