primitives icon indicating copy to clipboard operation
primitives copied to clipboard

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

Open jjenzz opened this issue 4 years ago • 26 comments

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 avatar Oct 21 '21 14:10 jjenzz

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

MaxMusing avatar Nov 24 '21 00:11 MaxMusing

Any updates on this? Also experiencing issues here

funwithtriangles avatar Jan 17 '22 16:01 funwithtriangles

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

jjenzz avatar Jan 17 '22 18:01 jjenzz

@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",
  },
})

funwithtriangles avatar Jan 18 '22 10:01 funwithtriangles

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.)

flex-soyoung avatar Apr 28 '22 08:04 flex-soyoung

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

benoitgrelard avatar Apr 28 '22 09:04 benoitgrelard

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.

jjenzz avatar Apr 28 '22 09:04 jjenzz

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.

JohnHershberg avatar Aug 04 '22 13:08 JohnHershberg

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'
    }
  }
});

syedmahmad avatar Oct 04 '22 11:10 syedmahmad

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>

ryantbrown avatar Feb 27 '23 23:02 ryantbrown

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

istarkov avatar Apr 12 '23 23:04 istarkov

@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

rijk avatar Jul 11 '23 09:07 rijk

Any updates?

flex-sangho-moon avatar Aug 14 '23 08:08 flex-sangho-moon

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

oyal avatar Jan 16 '24 06:01 oyal

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 :)

DasOhmoff avatar Apr 11 '24 19:04 DasOhmoff

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?

gabrieldesousah avatar Apr 28 '24 19:04 gabrieldesousah