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

[bug]: vertical separator not rendering #4818

Open
2 tasks done
OliverGilan opened this issue Sep 12, 2024 · 6 comments · May be fixed by #4819
Open
2 tasks done

[bug]: vertical separator not rendering #4818

OliverGilan opened this issue Sep 12, 2024 · 6 comments · May be fixed by #4819
Labels
bug Something isn't working

Comments

@OliverGilan
Copy link

Describe the bug

When using the separator with a "vertical" orientation it does not render properly. Looking at the browser dev tools it appears to have a size of 1x0 pixels.

Changing the default style here to use min-h-full instead of just h-full seems to fix this.

Seems to be the same as this issue encountered in the shadcn-svelte port

Affected component/components

Separator

How to reproduce

  1. Place a Separator in a flex parent with two other components and orientation "vertical"
<div className="flex flex-row flex-nowrap gap-4 h-fit">
          <p>Foo</p>
          <Separator orientation="vertical" />
          <p>Bar</p>
 </div>
  1. The separator will not appear
  2. Change style within components/ui/separator.tsx
<SeparatorPrimitive.Root
      ref={ref}
      decorative={decorative}
      orientation={orientation}
      className={cn(
        'shrink-0 bg-border',
        orientation === 'horizontal' ? 'h-[1px] w-full' : 'min-h-full w-[1px]',
        className
      )}
      {...props}
    />
  1. Separator will now render

Codesandbox/StackBlitz link

https://stackblitz.com/edit/stackblitz-starters-t7h9sc?file=components%2Fui%2Fseparator.tsx

Logs

No response

System Info

M2 Mac,
Firefox

Before submitting

  • I've made research efforts and searched the documentation
  • I've searched for existing issues
@OliverGilan OliverGilan added the bug Something isn't working label Sep 12, 2024
@OliverGilan
Copy link
Author

Opened a PR to help fix this!

@TharindaPrabhath
Copy link

In my case, I had to define the height explicitly in the className prop. Then, it was displayed.

@OliverGilan
Copy link
Author

Yes explicitly setting a height does work but the default behavior of the component should be that it fills up the height of the parent which isn't happening. Can always override that with the className prop even with this change

@TharindaPrabhath
Copy link

Yes, agree.

@gerardsiles
Copy link

gerardsiles commented Sep 17, 2024

it has an easy fix, on the primitive root change:

 className={cn(
    "shrink-0 bg-border",
    orientation === "horizontal" ? "h-[1px] w-full" : "h-full w-[1px]",
    className,
  )}

  for:

       className={cn(
    "shrink-0 bg-border",
    orientation === "horizontal" ? "h-[1px] w-full" : "min-h-full w-[1px]",
    className,
  )}

setting min-h-full should fix this this issue when set to vertical

@OliverGilan
Copy link
Author

Yes that is the fix I used and it's what I have in the PR I opened for this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants