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

SelectButton: Global PT invalid prop warning occurred #5621

Closed
redonearth opened this issue Dec 20, 2023 · 10 comments
Closed

SelectButton: Global PT invalid prop warning occurred #5621

redonearth opened this issue Dec 20, 2023 · 10 comments
Assignees
Labels
Component: Unstyled Issue related to unstyled/passthrough attributes Resolution: Stale Issue or pull request is inactivity and unfortunately it will be *closed* if there is no response Type: Bug Issue contains a defect related to a specific component.

Comments

@redonearth
Copy link
Contributor

Describe the bug

After recently updating Vite from 5.0.2 to 5.0.10, this warning message appeared in the Chrome browser console.
Fortunately, the app doesn't stretch and operates normally, but I'm reporting it because it's annoying.

image

Reproducer

No response

PrimeReact version

10.2.1

React version

18.x

Language

TypeScript

Build / Runtime

Vite

Browser(s)

Chrome 120

Steps to reproduce the behavior

No response

Expected behavior

No response

@redonearth redonearth added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Dec 20, 2023
@melloware melloware added Status: Needs Reproducer Issue needs a runnable reproducer and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Dec 20, 2023
Copy link

Please fork the CodeSandbox project or Stackblitz project and create a case demonstrating your bug report. This issue will be closed if no activities in 20 days.

@melloware
Copy link
Member

I can't reproduce can you please provide your exact SelectButton settings so I can reproduce it?

@redonearth
Copy link
Contributor Author

redonearth commented Dec 21, 2023

https://stackblitz.com/edit/vitejs-vite-qoogob?file=src%2Fmain.tsx

I succeeded in reproducing the error.
I set PrimeReactProvider in main.tsx and created a primeReactValue variable of APIOptions type.
Because I needed to set the global style of the Button component, I wrote a pt option in value. I didn't write the SelectButton option.
However, an error related to SelectButton occurs.
Presumably, there is a conflict in the settings of Button and SelectButton.

@redonearth
Copy link
Contributor Author

Additionally, I found that if I added the selectbutton settings (an empty object is also possible), the error message disappeared.

const primeReactValue: APIOptions = {
  pt: {
    button: {
      root: ({ props }: ButtonPassThroughMethodOptions) => ({
        className: classNames({
          'text-blue-500 bg-indigo-800 hover:bg-indigo-600 border-none':
            props.severity === 'secondary' && props.outlined,
        }),
        style: {
          fontWeight: 500,
          boxShadow: props.severity === 'secondary' && props.outlined && 'none',
        },
      }),
    },
    selectbutton: {},
  }
}

@melloware
Copy link
Member

@redonearth you had your Passthrough incorrect see my fixed example:

https://stackblitz.com/edit/vitejs-vite-xw2br5?file=src%2Fmain.tsx

@melloware melloware added Resolution: By Design The behavior in the issue is by design and the component exhibits the expected behavior and removed Status: Needs Reproducer Issue needs a runnable reproducer labels Dec 21, 2023
@melloware melloware closed this as not planned Won't fix, can't repro, duplicate, stale Dec 21, 2023
@redonearth
Copy link
Contributor Author

@melloware
I think my explanation wasn't sufficient.

I didn't need the pt of SelectButton, I only needed the global setting of Button.

So, I set the Button's pt as in the example code, and strangely enough, the error occurred on a page that used SelectButton instead of Button, or that used Button and SelectButton together.

@melloware melloware reopened this Dec 22, 2023
@github-actions github-actions bot added Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible and removed Resolution: By Design The behavior in the issue is by design and the component exhibits the expected behavior labels Dec 22, 2023
@melloware
Copy link
Member

Ok let me take another look your reproducer was confusing what you were trying to accomplish.

@melloware melloware added Type: Bug Issue contains a defect related to a specific component. and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Dec 22, 2023
@melloware melloware self-assigned this Dec 22, 2023
@melloware
Copy link
Member

melloware commented Dec 22, 2023

OK i took a deeper look and i am not sure how PrimeTek will want to fix this. Basically for styles specifically button and menu they have root components. However inside components like SelectButton and others they have an internal button style.

    selectbutton: {
        root: ({ props }) => ({
            className: classNames({ 'opacity-60 select-none pointer-events-none cursor-default': props.disabled })
        }),
        button: ({ context }) => ({
            className: classNames(
                'inline-flex cursor-pointer select-none items-center align-bottom text-center overflow-hidden relative',
                'px-4 py-3',
                'transition duration-200 border border-r-0',
                'first:rounded-l-md first:rounded-tr-none first:rounded-br-none last:border-r last:rounded-tl-none last:rounded-bl-none last:rounded-r-md',
                'focus:outline-none focus:outline-offset-0 focus:shadow-[0_0_0_0.2rem_rgba(191,219,254,1)] dark:focus:shadow-[0_0_0_0.2rem_rgba(147,197,253,0.5)]',
                {
                    'bg-white dark:bg-gray-900 text-gray-700 dark:text-white/80 border-gray-300 dark:border-blue-900/40 hover:bg-gray-50 dark:hover:bg-gray-800/80 ': !context.selected,
                    'bg-blue-500 border-blue-500 text-white hover:bg-blue-600': context.selected,
                    'opacity-60 select-none pointer-events-none cursor-default': context.disabled
                }
            )
        }),
        label: 'font-bold'
    }

So the button here is being found by the Global PT and applying your matching button name and the error is that it doesn't match as this buttton is a DIV where the main button is a <Button>

@melloware melloware assigned mertsincan and unassigned melloware Dec 22, 2023
@melloware melloware changed the title SelectButton: An invalid prop warning occurred. SelectButton: Global PT invalid prop warning occurred Jan 2, 2024
@melloware melloware added the Component: Unstyled Issue related to unstyled/passthrough attributes label Jan 2, 2024
Copy link

This issue has been automatically marked as stale. If this issue is still affecting you with the latest version, please leave any comment, and we will keep it open. We are sorry that we have not been able to prioritize it yet. If you have any new additional information, please include it with your comment!

@github-actions github-actions bot added the Resolution: Stale Issue or pull request is inactivity and unfortunately it will be *closed* if there is no response label Dec 28, 2024
Copy link

github-actions bot commented Jan 4, 2025

Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please create a new issue with up-to-date information. Thank you for your understanding!

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jan 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Unstyled Issue related to unstyled/passthrough attributes Resolution: Stale Issue or pull request is inactivity and unfortunately it will be *closed* if there is no response Type: Bug Issue contains a defect related to a specific component.
Projects
None yet
Development

No branches or pull requests

3 participants