tremor icon indicating copy to clipboard operation
tremor copied to clipboard

[Bug]: Date Picker is cut off when positioned on the right end of a page

Open lucafaggianelli opened this issue 2 years ago • 15 comments

Tremor Version

3.11.1

Link to minimal reproduction

none

Steps to reproduce

  1. Position a DatePicker at the right end of a page
  2. make it smaller than it normally is, i.e. :`className="w-58"``
  3. click on it so the calendar menu opens
  4. notice that the calendar is cut off
  5. an horizontal scroll bar appears in the page

What is expected?

the floating menu containing the calendar should be automatically moved to fit into the page

I would also accept an anchor option to force the menu to be anchored on the right of the input field rather than on the left

What is actually happening?

localhost_5173_ (2)

What browsers are you seeing the problem on?

Chrome

Any additional comments?

No response

lucafaggianelli avatar Nov 17 '23 10:11 lucafaggianelli

@severinlandolt hey, I feel I can fix this. Should I submit a PR?

rajdip-b avatar Nov 18 '23 03:11 rajdip-b

That would be great! I just assigned you. I have to go to sleep now🤣

severinlandolt avatar Nov 18 '23 03:11 severinlandolt

That would be great! I just assigned you. I have to go to sleep now🤣

Would try to submit the PR by the time you wake up!🤣

rajdip-b avatar Nov 18 '23 04:11 rajdip-b

Hey guys, I was experimenting with the component and sort of found it difficult to fix the alignment automatically. This is so because the Calendar is being rendered in an absolute component, which makes it very tricky to use flex boxes. I however, created a flag that will dock the calendar to left/right, thereby fixing the issue.

Here is a demo image image

Can anyone suggest any improvements? @severinlandolt @lucafaggianelli

rajdip-b avatar Nov 18 '23 12:11 rajdip-b

I've completed some tests and its basically a feature that our underlying library (headlessui) does not offer natively. CleanShot 2023-11-20 at 01 01 12@2x

Thank you @rajdip-b for your initial effort and suggesting a new prop. We will do some thinking around that an come back later!

severinlandolt avatar Nov 20 '23 00:11 severinlandolt

I've completed some tests and its basically a feature that our underlying library (headlessui) does not offer natively. CleanShot 2023-11-20 at 01 01 12@2x

Thank you @rajdip-b for your initial effort and suggesting a new prop. We will do some thinking around that an come back later!

Sure!!

rajdip-b avatar Nov 20 '23 00:11 rajdip-b

Yep indeed I reached the same conclusion on headlessui. Though I saw you use the lib floating ui as well in tremor, which seems more suited for this task.

About the new property, maybe I would call it "anchor" or something similar to make it more flexible so it could have values like right, left, center for the horizontal alignment and top, bottom, middle for the vertical one, I see many libs using this pattern.

lucafaggianelli avatar Nov 20 '23 08:11 lucafaggianelli

Yep indeed I reached the same conclusion on headlessui. Though I saw you use the lib floating ui as well in tremor, which seems more suited for this task.

About the new property, maybe I would call it "anchor" or something similar to make it more flexible so it could have values like right, left, center for the horizontal alignment and top, bottom, middle for the vertical one, I see many libs using this pattern.

Yeah even I did notice that. Should I proceed with the implementation, see what all changes I can implement? @lucafaggianelli @severinlandolt

rajdip-b avatar Nov 20 '23 09:11 rajdip-b

Good news: https://x.com/adamwathan/status/1729274129264624056?s=20

severinlandolt avatar Nov 28 '23 03:11 severinlandolt

Good news: https://x.com/adamwathan/status/1729274129264624056?s=20

I guess this issue can be closed then?

rajdip-b avatar Nov 28 '23 04:11 rajdip-b

I will keep it open until Headless UI has been updated

severinlandolt avatar Nov 28 '23 16:11 severinlandolt

Sure!

rajdip-b avatar Nov 29 '23 05:11 rajdip-b

Any update on this?

rlancejohnson avatar Mar 06 '24 20:03 rlancejohnson

Hi @rlancejohnson → still blocked! Waiting for headless ui 4.0.

severinlandolt avatar Mar 06 '24 20:03 severinlandolt

Hi @lucafaggianelli @rajdip-b @rlancejohnson! Brief update: The overflow problem still persists and it looks like that this won't be fixable soon. I will update this asap once there is a fixing headless ui release.

If you are in desperate need of a date picker with improved positioning, it's worth taking a look here: https://raw.tremor.so/docs/inputs/date-range-picker

CleanShot 2024-04-19 at 20 56 56@2x

severinlandolt avatar Apr 19 '24 18:04 severinlandolt