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

AutoComplete Show Dropdown When Clicked #2445

Closed
EmirBoyaci opened this issue Nov 18, 2021 · 10 comments · Fixed by #2452
Closed

AutoComplete Show Dropdown When Clicked #2445

EmirBoyaci opened this issue Nov 18, 2021 · 10 comments · Fixed by #2452
Labels
Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add
Milestone

Comments

@EmirBoyaci
Copy link
Contributor

EmirBoyaci commented Nov 18, 2021

[X] feature request

Normally, when AutoComplete clicked we want to see the selectable items however current AutoComplete components doesn't have this feature. It only shows selectable items when dropdown prop is true and dropdown icon is clicked but, we want when user clicks inside AutoComplete it will show dropdown and selectable items. How can we add that feature to AutoComplete component? Is it possible to do on our own or need PR?

  • React version: 17.0.2
  • PrimeReact version: 7.0.0
  • Browser: all

  • Language: TypeScript 4.4.4

@EmirBoyaci
Copy link
Contributor Author

@melloware have you ever face with that problem before?

@melloware
Copy link
Member

Let me investigate. It might be possible now or it might have to be a new property.

@melloware
Copy link
Member

melloware commented Nov 18, 2021

@EmirBoyaci yep here you go with working example...

Sorry I messed up my CodeSandbox. But here is its...

const ref = useRef(null);

<AutoComplete ref={ref} onClick={(e) => ref.current.search(e, "", "dropdown")} />

@melloware
Copy link
Member

@EmirBoyaci if after testing you find it meets your needs please close the ticket.

@EmirBoyaci
Copy link
Contributor Author

@EmirBoyaci if after testing you find it meets your needs please close the ticket.

Thanks for your quick reply! That's what I need but just one more question. I didn't used refs with TypeScript before so I couldn't find the correct type for that:

const ref = useRef(null);

The first error that I got is:
image

If I use non-null assertion operator I've got 2nd error which is:
image

The solution that you provide is works below but I wanna use correct type for useRef. Do you know the correct type for the useRef?

const ref = useRef<any>(null);

@melloware
Copy link
Member

melloware commented Nov 18, 2021

Here is a working example:

https://codesandbox.io/s/primereact-test-forked-5jgb7?file=/src/index.tsx

A for the Search error its only because the search method is not listed in the TypeScript file but it is definitely on the component. I used // @ts-ignore to hide the warning.

@melloware
Copy link
Member

Please close this ticket once you have verified my code above. Thanks!

@EmirBoyaci
Copy link
Contributor Author

Here is a working example:

https://codesandbox.io/s/primereact-test-forked-5jgb7?file=/src/index.tsx

A for the Search error its only because the search method is not listed in the TypeScript file but it is definitely on the component. I used // @ts-ignore to hide the warning.

I just thought maybe we have a solution different than @ts-ignore but it works perfectly! Thanks for all :)

@melloware
Copy link
Member

@EmirBoyaci you can re-open this I added the search method to the TS doc in the PR.

@EmirBoyaci
Copy link
Contributor Author

I’ve reopened

@EmirBoyaci you can re-open this I added the search method to the TS doc in the PR.

@EmirBoyaci EmirBoyaci reopened this Nov 20, 2021
@mertsincan mertsincan added Type: Bug Issue contains a defect related to a specific component. Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add and removed Type: Bug Issue contains a defect related to a specific component. labels Dec 10, 2021
@mertsincan mertsincan modified the milestones: 8.0.0, 7.1.0 Dec 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants