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

SegmentedControl always setting border-left/top-color to transparent ignoring orientation #3669

Closed
jksaunders opened this issue Mar 3, 2023 · 0 comments · Fixed by #3670
Closed

Comments

@jksaunders
Copy link
Contributor

jksaunders commented Mar 3, 2023

What package has an issue

@mantine/core

Describe the bug

The SegmentedControl component's style API does not allow setting the borderLeftColor/borderRightColor for the control immediately to the left (or above if vertical) of the active control.

The color for both borders is being overwritten with a transparent value. Unless I'm misunderstanding something, I believe if horizontal, the borderTopColor should not be set to transparent, and if vertical, the borderLeftColor should not be set to transparent.

Use case: creating a nav that behaves like that Tabs component in Mantine, but has the sliding animation. Probably another way to achieve this, but happy to fix this anyway!

image

What version of @mantine/hooks page do you have in package.json?

6.0.0

If possible, please include a link to a codesandbox with the reproduced problem

https://codesandbox.io/s/jolly-heyrovsky-qrintp?file=/src/App.tsx

Do you know how to fix the issue

Yes

Are you willing to participate in fixing this issue and create a pull request with the fix

Yes

Possible fix

In this file: /src/mantine-core/src/SegmentedControl/SegmentedControl.styles.ts:

The control style should be:

controlActive: {
        borderLeftColor: 'transparent !important',
        borderTopColor: 'transparent !important',

        [`& + .${getStylesRef('control')}`]: {
          [vertical  ? 'borderTopColor' : ''borderLeftColor']: 'transparent !important', // This key changed to be only one of `borderTopColor` or `borderLeftColor`
        },
        borderRadius: theme.fn.radius(radius),
        boxShadow: shouldAnimate
          ? color || theme.colorScheme === 'dark'
            ? 'none'
            : theme.shadows.xs
          : undefined,
        backgroundColor: shouldAnimate
          ? color
            ? colors.background
            : theme.colorScheme === 'dark'
            ? theme.colors.dark[5]
            : theme.white
          : undefined,
      },
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

Successfully merging a pull request may close this issue.

1 participant