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

Dropdown: Tailwind optionDisabled with function not working #5676

Closed
igo opened this issue Jan 2, 2024 · 5 comments · Fixed by #5677
Closed

Dropdown: Tailwind optionDisabled with function not working #5676

igo opened this issue Jan 2, 2024 · 5 comments · Fixed by #5677
Assignees
Labels
Component: Tailwind Tailwind specific issue
Milestone

Comments

@igo
Copy link

igo commented Jan 2, 2024

Describe the bug

optionDisabled does not work if function is provided

Reproducer

No response

PrimeReact version

10.2.1

React version

17.x

Language

TypeScript

Build / Runtime

Create React App (CRA)

Browser(s)

No response

Steps to reproduce the behavior

import React, { useState } from 'react';
import { Dropdown } from 'primereact/dropdown';

export default function UnstyledDemo() {
  const [selectedCity, setSelectedCity] = useState(null);
  const cities = [
    { name: 'New York', code: 'NY' },
    { name: 'Rome', code: 'RM' },
    { name: 'London', code: 'LDN' },
    { name: 'Istanbul', code: 'IST' },
    { name: 'Paris', code: 'PRS' },
  ];

  return (
    <div className="card flex justify-center">
      <Dropdown
        value={selectedCity}
        onChange={(e) => setSelectedCity(e.value)}
        options={cities}
        optionLabel="name"
        optionDisabled={(o) => {
          console.log({ o, disable: o.code == 'NY' });
          return o.code == 'NY';
        }}
        placeholder="Select a City"
        className="w-full md:w-14rem"
      />
    </div>
  );
}

Expected behavior

New York cannot be selected

@igo igo added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Jan 2, 2024
@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 Jan 2, 2024
@kl-nevermore
Copy link
Contributor

@igo
Copy link
Author

igo commented Jan 3, 2024

Indeed that one is working. Seems that it is not working only with Tailwind: <PrimeReactProvider value={{ unstyled: true, pt: Tailwind }}>

@melloware melloware added Component: Tailwind Tailwind specific issue and removed Type: Bug Issue contains a defect related to a specific component. labels Jan 3, 2024
@melloware melloware changed the title Dropdown: optionDisabled with function not working Dropdown: Tailwind optionDisabled with function not working Jan 3, 2024
@melloware
Copy link
Member

@igo i updated the ticket label to Tailwind from Bug

melloware added a commit to melloware/primereact that referenced this issue Jan 3, 2024
@melloware melloware self-assigned this Jan 3, 2024
@melloware melloware added this to the 10.2.2 milestone Jan 3, 2024
@igo
Copy link
Author

igo commented Jan 3, 2024

@melloware just checking, did you only fix the styles in that commit? what about possibility to select option that is supposed to be disabled

@melloware
Copy link
Member

melloware commented Jan 3, 2024

@igo but these two Tailwind styles select-none pointer-events-none prevent the item from being selected.

It should work just like PrimeTek built in theme now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Tailwind Tailwind specific issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants