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

[ScrollArea] display: table is altering width on a vertical scroll element #2722

Closed
GetPsyched opened this issue Feb 24, 2024 · 6 comments
Closed

Comments

@GetPsyched
Copy link

GetPsyched commented Feb 24, 2024

Bug report

Reference:

{/**
* `display: table` ensures our content div will match the size of its children in both
* horizontal and vertical axis so we can determine if scroll width/height changed and
* recalculate thumb sizes. This doesn't account for children with *percentage*
* widths that change. We'll wait to see what use-cases consumers come up with there
* before trying to resolve it.
*/}
<div ref={context.onContentChange} style={{ minWidth: '100%', display: 'table' }}>
{children}
</div>

Current Behavior

Due to the display: table property, my list which is supposed to scroll vertically, is now being expanded horizontally as well since the text overflows, I've set the text to truncate based on the parent's width but because of this property my parent is expanding to fit the children.

image

Expected behavior

Respect the width if scroll is vertical and vice versa.

image

Suggested solution

Maybe another way to expand to full size which targets only one dimension?

Your environment

Software Name(s) Version
Radix Package(s) react-scroll-area 1.0.5
React n/a 18
Browser Firefox 123.0
Assistive tech n/a n/a
Node n/a 20.10.0
npm/yarn npm 10.2.3
Operating System NixOS 23.11
@resulyrt93
Copy link

Hey team, we also suffering with that problem. Is there any progress about it?

@benoitgrelard
Copy link
Collaborator

Duplicate of #926

@benoitgrelard benoitgrelard marked this as a duplicate of #926 Mar 12, 2024
@benoitgrelard
Copy link
Collaborator

Planning on addressing this soon.

@bertkdowns
Copy link

bertkdowns commented Sep 10, 2024

If anyone is still having this issue, one way you can force the width to be the same as a parent is adding manual styling to the div with display:table like so:

<ScrollArea className='h-full'>
    <style>
        {`
        [data-radix-scroll-area-viewport] div {
            display:block !important;
        }
        `}
    </style>
    {/*content goes here*/}
</ScrollArea>

@GetPsyched
Copy link
Author

But I suppose this is fixed in #2945? I haven't tested it since I don't think this has made it into any release yet.

@bfourgeaud
Copy link

bfourgeaud commented Sep 13, 2024

I updated to 1.1.0 but still display:table that messes everything up ...
Any udpades on when it will be merged into a new version ?

I added a *:!block selector to force the children to display correctly for now.

<ScrollAreaPrimitive.Viewport className="size-full rounded-[inherit] *:!block">
    {children}
</ScrollAreaPrimitive.Viewport>

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

No branches or pull requests

5 participants