Skip to content

Datepicker popover position with CustomInput prop is always at the center of the CustomInput container, regardless of which element ref is attached #3897

@praneetha-ck-ps

Description

@praneetha-ck-ps

Describe the bug
The Datepicker popover position is always in the middle of CustomInput, it does not consider the ref element's position.

To Reproduce
In the following example, despite ref being set on the button, the calendar popover is positioned with respect to the outer div, specifically positioned with respect to center of div.

() => {
  const [startDate, setStartDate] = useState(new Date());
  const buttonRef=React.useRef(null);
  const ExampleCustomInput = forwardRef(({ value, onClick }, ref) => (
  <div style={{display:'flex', border:"1px solid red", justifyContent:"space-between"}}>
  {value}
    <button className="example-custom-input" onClick={onClick} ref={ref}>
      >>
    </button>
    </div>
  ));
  return (
    <DatePicker
      selected={startDate}
      onChange={(date) => setStartDate(date)}
      customInput={<ExampleCustomInput />}
    />
  );
};

Expected behavior
Calendar popover should be positioned with respect to the button

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):
Screenshot 2023-01-12 at 7 00 34 PM

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions