primefaces / primereact

The Most Complete React UI Component Library
https://primereact.org
MIT License
7.06k stars 1.06k forks source link

Password: Invalid PT props #6404

Closed imnash21 closed 7 months ago

imnash21 commented 7 months ago

Describe the bug

In the Features Tab you can see the invalid prop can call directly but not, when I read the API Tab you can call the "invalid" inside pt prop. That's why I got an error everytime I call "invalid" directly.

IMG_20240417_113144

IMG_20240417_113452

Reproducer

No response

PrimeReact version

10.6.3

React version

18.x

Language

TypeScript

Build / Runtime

Vite

Browser(s)

No response

Steps to reproduce the behavior

No response

Expected behavior

No response

Rekl0w commented 7 months ago

6407 i created pull request for this.

melloware commented 7 months ago

@Rekl0w i fixed this the right way by removing those two PT props. If you want to use invalid in PT you would use the props.invalid on the input PT object

Rekl0w commented 7 months ago

@melloware You deleted it from pt options but now there is no explanation for invalid at props too. I can add to there.

melloware commented 7 months ago

OH those props were just in the wrong place. I will fix.

melloware commented 7 months ago

They were in PT when they should have been in main props.

Rekl0w commented 7 months ago

Okay but he mentioned that if he calls directly invalid, it gets error. That's why i added invalid={true}

melloware commented 7 months ago

yeah but that is not correct. here is the proper way to use invalid with Passthrough.

https://stackblitz.com/edit/xmhzeu?file=src%2FApp.jsx

      <Password
        invalid
        pt={{
          input: ({ props }) => {
            if (props.invalid) return 'invalid-css-class';
          },
        }}
      />

that will add the invalid-css-class to the Password only if its invalid.

imnash21 commented 7 months ago

Thank you for responses, now I can continue to work and test it.