Skip to content

Commit

Permalink
fix: popover id
Browse files Browse the repository at this point in the history
  • Loading branch information
aboveyunhai committed Feb 17, 2025
1 parent 6a0050c commit 9175dca
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
6 changes: 2 additions & 4 deletions example/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ const App = () => {
</Flex>
{/* chakra ui add prefix for the trigger for some reasons? */}
<Flex gap="1rem" alignItems="center">
<label>Default:</label>
<label htmlFor="default">Default:</label>
<SingleDatepicker
id="default"
date={date}
Expand Down Expand Up @@ -238,9 +238,7 @@ const App = () => {
</Button>
</Flex>
<Flex gap="1rem" alignItems="center">
<label htmlFor={`popover-trigger-default-range`}>
Default:
</label>
<label htmlFor={`default-range`}>Default:</label>
<RangeDatepicker
id="default-range"
selectedDates={selectedDates}
Expand Down
4 changes: 3 additions & 1 deletion src/range.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@ export const RangeDatepicker: React.FC<RangeDatepickerProps> = ({

return (
<Popover.Root
ids={{
trigger: id,
}}
open={open}
onOpenChange={(e) => {
if (e.open) {
Expand Down Expand Up @@ -207,7 +210,6 @@ export const RangeDatepicker: React.FC<RangeDatepickerProps> = ({
<Flex position="relative" alignItems={'center'}>
<Popover.Anchor>
<Input
id={id}
onKeyUp={(e) => {
if (e.key === ' ' && !open) {
e.preventDefault();
Expand Down
5 changes: 4 additions & 1 deletion src/single.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,9 @@ export const SingleDatepicker: React.FC<SingleDatepickerProps> = ({

return (
<Popover.Root
ids={{
trigger: id,
}}
open={open}
onOpenChange={(e) => {
if (e.open) {
Expand All @@ -196,6 +199,7 @@ export const SingleDatepicker: React.FC<SingleDatepickerProps> = ({
portalled={usePortal}
lazyMount={true}
unmountOnExit={true}
{...restProps.propsConfigs?.popoverCompProps?.popoverRootProps}
>
{!children && (restProps.triggerVariant ?? 'default') === 'default' ? (
<Popover.Trigger asChild>
Expand All @@ -219,7 +223,6 @@ export const SingleDatepicker: React.FC<SingleDatepickerProps> = ({
<Flex position="relative" alignItems={'center'}>
<Popover.Anchor>
<Input
id={id}
onKeyUp={(e) => {
if (e.key === ' ' && !open) {
e.preventDefault();
Expand Down
2 changes: 2 additions & 0 deletions src/utils/commonTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
StackProps,
SeparatorProps,
PopoverContentProps,
PopoverRootProps,
} from '@chakra-ui/react';
import { DateObj } from 'dayzed';

Expand All @@ -30,6 +31,7 @@ export interface DayOfMonthBtnStyleProps {
}

export interface PopoverCompProps {
popoverRootProps?: PopoverRootProps;
popoverContentProps?: PopoverContentProps;
popoverBodyProps?: PopoverBodyProps;
}
Expand Down

0 comments on commit 9175dca

Please sign in to comment.