themesberg / themesberg/flowbite-react

Allow Floating Strategy to be Configurable for Popover

Open
#1,504 8 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

discussion
Dominant language
TypeScript
Stars
2.1k
Forks
506
PR merge metrics
No merged PRs in 30d

Description

  • I have searched the Issues to see if this bug has already been reported
  • I have tested the latest version

Summary

Describe how it should work, and provide examples of the solution, which might include screenshots or code snippets.

Hello and thanks for providing this reference implementation for Flowbite. I have a use case for the Popover that is not currently covered but can easily be added.

I am using a Popover component inside of a parent which is overflow: auto set. This means the popover is cut off. See screen shot.

Screenshot 2024-10-25 at 11 57 19 AM

This is due to @floating-ui/react using position: absolute by default.

The good news is that useFloating has a strategy prop that can be passed to override this if necessary. In scenarios like mine, position: fixed is needed. I did some testing, and it works well. See screen shot.

Screenshot 2024-10-25 at 11 59 55 AM

The popover is still attached to the reference element and scrolls along with it.

Context

What are you trying to accomplish? How is your use case affected by not having this feature?

Popover should be updated to accept a strategy prop of type:

strategy?: 'absolute' | 'fixed';

This is passed to useFloating from the @floating-ui/react library.

Without this feature, popovers are cut off in parents that have overflow other than visible.

I'm happy to create a PR for this if it will help.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the Popover component and its @floating-ui/react useFloating call. Add the optional absolute/fixed strategy prop and verify that it reaches useFloating; done when Popover can use fixed positioning for parents with non-visible overflow.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.