Skip to content

Added anchor option to date picker to prevent overflow #63

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

dupasj
Copy link

@dupasj dupasj commented Jan 26, 2025

Summary

This pull request introduces a new anchor option to the date picker component, allowing better positioning control when the popup might overflow the user's screen.

Changes Introduced

Added an anchor prop with the following options:

  • "left": Anchors the date picker popup to the left of the input element.
  • "right": Anchors the date picker popup to the right of the input element.
  • "auto" (default): Automatically adjusts the position to prevent overflow. The date picker popup will first anchor to the left of the input element. Note: There might be a slight "flash" when the component first appears outside the screen due to the delay of the useEffect hook.

Why This Change?

Previously, the date picker could overflow the viewport if the input element was near the right edge of the screen. This enhancement improves the user experience by ensuring the popup remains fully visible within the viewport.

Potential Improvements

Future enhancements could include:

  • Adding an offset option to allow better spacing adjustments.
  • Using CSS translations instead of repositioning to avoid layout shifts and improve visual appearance.

Documentation

Updated the README to include details about the new anchor option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant