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] Content with ellipsis CSS bursts out of container. #926

Closed
jjenzz opened this issue Oct 21, 2021 · 17 comments · Fixed by #2945
Closed

[ScrollArea] Content with ellipsis CSS bursts out of container. #926

jjenzz opened this issue Oct 21, 2021 · 17 comments · Fixed by #2945
Assignees
Labels
Difficulty: Medium This issue is quite difficult Package: react/scroll-area Priority: Medium Medium priority issue Type: Bug Confirmed bug
Milestone

Comments

@jjenzz
Copy link
Contributor

jjenzz commented Oct 21, 2021

Issue: https://codesandbox.io/s/frosty-cerf-poy3y?file=/src/styles.css
Example of native scrollable without this issue: https://codepen.io/jjenzz/pen/jOLMjvJ

I'm wondering if we still need the display: table stuff now so will investigate getting rid of that as a potential solution at some stage.

@jjenzz jjenzz added the Type: Bug Confirmed bug label Oct 21, 2021
@MaxMusing
Copy link

This is blocking us from adopting Scroll Area in the one component we really want it.

@funwithtriangles
Copy link

Any updates on this? Also experiencing issues here

@jjenzz
Copy link
Contributor Author

jjenzz commented Jan 17, 2022

@funwithtriangles We haven't had time to look into any of this yet I'm afraid so no updates.

@funwithtriangles
Copy link

@jjenzz no worries. For anyone who's also having problems, I'm just overriding the inline styles for now to get rid of display: table:

const StyledViewport = styled(ScrollAreaPrimitive.Viewport, {
  ...

  "> div[style]": {
    display: "block !important",
  },
})

@flex-soyoung
Copy link

I hope this issue is resolved quickly. 🙏 ScrollArea is a really nice component, but this issues make it difficult to use. (I wonder if there is any reason to keep display: table.)

@benoitgrelard
Copy link
Collaborator

@jjenzz do you remember what the reason why for display: table originally?

@jjenzz
Copy link
Contributor Author

jjenzz commented Apr 28, 2022

it was something to do with making that div the same width of the content for overflow-x calculations i believe.

if you remove it and test that things overflow the horizontal axis in a way that matches native scroll behaviour then should be good.

@JohnHershberg
Copy link

I have a similar problem and ended up overriding the table to flex instead. In my case I need to stack 2 items per row and I can't see how to achieve that with table. With flex I can set it to flex-wrap, and set each item to be 50% of the width so only 2 items fit before wrapping.

@syedmahmad
Copy link

syedmahmad commented Oct 4, 2022

I have a similar problem and I ended up overriding the table to block as follows:

// the viewport area of the scroll area
const ScrollAreaViewport = styled(ScrollAreaPrimitive.Viewport)({
  // all these settings pulled from radix example
  width: '100%',
  height: '100%',
  borderRadius: 'inherit',
  '&[data-radix-scroll-area-viewport]': {
    '& > :first-of-type': {
      display: 'block !important'
    }
  }
});

@ryantbrown
Copy link

With Tailwind, adding [&>div]:!block as a class to RadixScrollArea.Viewport fixes the issue.

For example:

<RadixScrollArea.Root className="overflow-hidden">
    <RadixScrollArea.Viewport className="w-full h-full [&>div]:!block">
        {children}
    </RadixScrollArea.Viewport>
</RadixScrollArea.Root>

@istarkov
Copy link

The other workaround is to place div with display:grid as a child of the Viewport, allows to not override viewport style

@rijk
Copy link

rijk commented Jul 11, 2023

@jjenzz do you remember what the reason why for display: table originally?

When I changed the display from display: table to display: block, I noticed that the bottom padding of the child div was collapsed:

image

display: block:

image

@flex-sangho-moon
Copy link

Any updates?

@oyal
Copy link

oyal commented Jan 16, 2024

It's been over two years, have there been any updates?

@DasOhmoff
Copy link

DasOhmoff commented Apr 11, 2024

I also have this very same issue. It messes up the layout of the children especially when flexbox is used there. Would be great to fix it :)

@gabrieldesousah
Copy link

This is probably the more inconvenient problem in scrollarea =/
Use <RadixScrollArea.Viewport className="w-full h-full [&>div]:!block"> helps a lot.
There some reason to still remain display: table?

@jjenzz
Copy link
Contributor Author

jjenzz commented Jul 2, 2024

it might be possible to remove display: table and instead use height: min-content; width: min-content instead now: https://caniuse.com/?search=min-content

edit: ah, i just saw there is a PR with an alternate approach already 🙈 ignore!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Difficulty: Medium This issue is quite difficult Package: react/scroll-area Priority: Medium Medium priority issue Type: Bug Confirmed bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

16 participants