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] - DateInput extendVariants not working #3502

Closed
rettimo opened this issue Jul 18, 2024 · 7 comments · Fixed by #3503
Closed

[BUG] - DateInput extendVariants not working #3502

rettimo opened this issue Jul 18, 2024 · 7 comments · Fixed by #3503
Assignees
Labels
🟠 Priority: High 📦 Scope : Components Related to the components 🐛 Type: Bug Something isn't working

Comments

@rettimo
Copy link

rettimo commented Jul 18, 2024

NextUI Version

2.4.3

Describe the bug

An error occurs when using DateInput with extendVariants.

import {
  extendVariants,
  DateInput as NextUiDateInput,
  DateInputProps as NextUiDateInputProps,
} from '@nextui-org/react';

import { ForwardRefRenderFunction, ReactElement } from 'react';

export interface DateInputProps extends NextUiDateInputProps {}

export const DateInput: ForwardRefRenderFunction<ReactElement, DateInputProps> = extendVariants(NextUiDateInput, {});

image

Your Example Website or App

No response

Steps to Reproduce the Bug or Issue

  1. Use DateInput with extendVariants
  2. Get an error

Expected behavior

Ability to use extendVariants as in all other components

Screenshots or Videos

No response

Operating System Version

macOS Sonoma 14.5

Browser

Chrome

Copy link

linear bot commented Jul 18, 2024

@hugo-lovighi
Copy link

I have the same issue extending Spinner

@wingkwong
Copy link
Member

@hugo-lovighi can you also share your code?

@hugo-lovighi
Copy link

hugo-lovighi commented Jul 18, 2024

Of cource !
I add a new size to nextui spinner according to https://nextui.org/docs/customization/custom-variants documentation.

Spinner.tsx component:

import { Spinner as NextUiSpinner } from '@nextui-org/spinner'
import { SpinnerProps } from '@nextui-org/spinner/dist/spinner'
import { extendVariants } from '@nextui-org/system'

export const ExtendedSpinner = extendVariants(NextUiSpinner, {
    variants: {
        size: {
            xs: {
                wrapper: 'h-4 w-4',
                circle1: 'border-2',
                circle2: 'border-2',
                label: 'text-xs'
            },
        },
    },
})

type ExtendedSpinnerProps = Omit<SpinnerProps, 'size'> & {
    size?: 'xs' | 'sm' | 'md' | 'lg'
}

export const Spinner = (props: ExtendedSpinnerProps) => <ExtendedSpinner {...props} />

package.json after this nextui update:

        "@nextui-org/pagination": "^2.0.33",
        "@nextui-org/progress": "^2.0.31",
        "@nextui-org/radio": "^2.1.2",
        "@nextui-org/skeleton": "^2.0.29",
        "@nextui-org/spinner": "^2.0.30",
        "@nextui-org/switch": "^2.0.31",
        "@nextui-org/system": "^2.2.2",
        "@nextui-org/tabs": "^2.0.32",
        "@nextui-org/theme": "^2.2.6",

to

        "@nextui-org/pagination": "^2.0.34",
        "@nextui-org/progress": "^2.0.32",
        "@nextui-org/radio": "^2.1.3",
        "@nextui-org/skeleton": "^2.0.30",
        "@nextui-org/spinner": "^2.0.31",
        "@nextui-org/switch": "^2.0.32",
        "@nextui-org/system": "^2.2.3",
        "@nextui-org/tabs": "^2.0.33",
        "@nextui-org/theme": "^2.2.7",

I got this error when I try to render the Spinner with the variant size (other sizes working fine)

Example.tsx:

...
<Spinner className="relative" size="xs" />
...

Screenshot from 2024-07-18 14-10-43

I try to fix this issue but without success.

@wingkwong
Copy link
Member

@hugo-lovighi thanks. I got the problem and made the PR already.

@hugo-lovighi
Copy link

hugo-lovighi commented Jul 18, 2024

Thanks a lot ! We downgraded temporarily the dependencies. We are waiting patiently :)

@sethchurch
Copy link

I've been running into this issue as well. It seems adding a key of defaultVariants with a empty object value seems to work as a workaround for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🟠 Priority: High 📦 Scope : Components Related to the components 🐛 Type: Bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants