Skip to content
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

Popovers aren't scrolling with the page and should instead lock scroll when open #110

Open
lghcdh opened this issue Sep 26, 2024 · 9 comments

Comments

@lghcdh
Copy link

lghcdh commented Sep 26, 2024

I looked to see if this was ane existing issue, but could not see one.

Using the same code provided here: https://fluxui.dev/layouts/sidebar

When opening a popover menu, it is never fixed to to the parent element, even if the parent has a relative class applied to it.

Attached video shows this in action:

Untitled.Video.September.26.2024.7_04.PM.mp4
@omniith
Copy link

omniith commented Oct 1, 2024

Yes, facing the same issue. Waiting to see the solution for this.

@calebporzio
Copy link
Contributor

This a really tough one and I wondered what other libraries do, and most libraries disable scrolling when a dropdown of any kind is open to prevent things like this.

Unforunately implementing scroll-lock isn't trivial and could be source of more bugs so I want to make sure we want to introduce it before we do, but just pinging here to let you all know that it's on my mind and will try to address it shortly.

@ahscc
Copy link

ahscc commented Oct 18, 2024

Just ran into this issue trying to implement a dropdown in the sidebar. Are there any recommended work arounds?

@relaypilot
Copy link

Closing the dropdown on a scroll event could be a good solution?

@sertxudev
Copy link

@lghcdh I ran into this problem a few weeks ago, the solution for me was to make the main content scrollable, not the whole page scrollable. I don't know if I make myself clear, I don't have the code in front of me right now. 😅

@LasseRafn
Copy link

actually dig the idea of scroll = close dropdown. Maybe after scrolling X pixels, it closes (to prevent small accidental scrolls from closing)

@calebporzio calebporzio changed the title Dropdown element is not relative to its container (Sidebar) Popovers should lock scroll when open Oct 23, 2024
@calebporzio calebporzio changed the title Popovers should lock scroll when open Popovers aren't scrolling with the page and should instead lock scroll when open Oct 23, 2024
@RyanPaiva56
Copy link

actually dig the idea of scroll = close dropdown. Maybe after scrolling X pixels, it closes (to prevent small accidental scrolls from closing)

I think most libraries do close by default when scrolling, some make this optional just in case you want a popover to persist. If you don't close, it scrolls with the page. I don't think scroll locking in any scenario is a good idea.

@calebporzio
Copy link
Contributor

Intresting, so maybe there's two behaviors:
A) close on scroll
B) lock scroll

Maybe tooltips and popovers close on scroll, and select dropdowns and modals lock scroll?

Curious what other libraries do. Thanks for all the thoughts on this.

@itsgrimace
Copy link

This is most likely related. Things get whacky when you add a tooltip into a modal, the size of the modal box changes and adds scrolling overflow to x and y axis. See example.

<div>
    <flux:modal.trigger name="edit-profile">
        <flux:button>Edit profile</flux:button>
    </flux:modal.trigger>
    
    <flux:modal name="edit-profile" class="md:w-96 space-y-6">
        <div>
            <flux:heading size="lg">Update profile</flux:heading>
            <flux:subheading>Make changes to your personal details.</flux:subheading>
        </div>
    
        <flux:input label="Name" placeholder="Your name" />
    
        <flux:input label="Date of birth" type="date" />
    
        <div class="flex">
            <flux:spacer />
            <flux:tooltip content="Settings">
                <flux:button type="submit" variant="primary">Save changes</flux:button>
            </flux:tooltip>
        </div>
    </flux:modal>
</div>

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

No branches or pull requests

9 participants