react-native-paper icon indicating copy to clipboard operation
react-native-paper copied to clipboard

feat: dropdown component

Open omneimneh opened this issue 4 years ago • 11 comments

Summary

This PR introduces a new component which is Dropdown and Dropdown.Option, I noticed that the native Picker in react-native isn't very customizable and doesn't look nice with other react-native-paper components.

I found other libraries on npm such as 'react-native-paper-dropdown' and 'react-native-material-dropdown' however I tested these libraries, they appear to have an issue displaying on the web, when developing this I went through the same problem because I was following their approach at first so I had to change a little bit. I will try to explain it briefly: If we want to create a dropdown in react (only web), we can use a div with relative position to parent by following this approach https://stackoverflow.com/a/5209833, however we will need to set the z-index to prevent other components down in the page to appear on top of the dropdown. With react-native it's a little more complicated since all components by default have a relative position a a z-index preset to 0, so even if we increase the z-index of the dropdown we still can't make it appear above other components unless we change the z-index of the parent (and maybe other parents in the dom tree as well) https://stackoverflow.com/a/35326592. The approach I took involved using a portal and computing the location of the dropdown when the user clicks on the component and displaying it, it works because the portal renders the dropdown at the top of the tree. But in this approach I assumed that the Provider component will provide the Protal.Host.

Test plan

Screenshot_20210127-110722 Screenshot_20210127-110657

I already provided an example in my PR, but I believe this is not ready to merge yet since there are tests and docs to add and maybe some refactoring required. Other features can be added as well like completely custom components (here I'm just using List.Item) and making the dropdown searchable... but I'll let you guys be the judge.

I'll keep updating the PR as much as I can until it's ready to merge and if anyone can also contribute with this it would be great

omneimneh avatar Jan 27 '21 08:01 omneimneh

Hey @omneimneh, thank you for your pull request 🤗. The documentation from this branch can be viewed here.

callstack-bot avatar Jan 27 '21 08:01 callstack-bot

@brunohkbx any updates on this? thanks 😃

omneimneh avatar Feb 20 '21 19:02 omneimneh

@omneimneh I just realized that there's a missing top/bottom margin in the dropdown. Check it out:

From MD guide: https://material.io/components/menus#specs Screenshot from 2021-02-23 00-02-25

dropdown

brunohkbx avatar Feb 23 '21 03:02 brunohkbx

Also, can we support this error state?

Screenshot from 2021-02-23 00-34-13

brunohkbx avatar Feb 23 '21 03:02 brunohkbx

Hello 👋, this pull request has been open for more than 2 months with no activity on it. If you think this is still necessary with the latest version, please comment and ping a maintainer to get this reviewed, otherwise it will be closed automatically in 7 days.

github-actions[bot] avatar Apr 26 '21 00:04 github-actions[bot]

@brunohkbx Hello, please let me know if this is going live

avvari-da avatar May 03 '21 20:05 avvari-da

hey @lukewalczak can you please take a look when you have some time?

brunohkbx avatar May 06 '21 12:05 brunohkbx

I'm working on a similar component but I only tested it on the web for now but it will improve in the coming month: https://github.com/web-ridge/react-native-paper-autocomplete

RichardLindhout avatar Jun 04 '21 18:06 RichardLindhout

How do I intall this component in my app? I'm using Expo

NahumG10 avatar Dec 12 '21 00:12 NahumG10

+1 I'm using react-native-paper and wanted to use a dropdown picker the Project as well, unfortunately did not find one with good web & react-native support as mentioned at the start of this PR. Looking for other solutions now.

MartijnGevaert avatar Feb 09 '22 23:02 MartijnGevaert

@lukewalczak , @omneimneh : Are there any news?

Angelk90 avatar Mar 20 '22 16:03 Angelk90

Any news on this PR?

jigarzon avatar Mar 02 '23 14:03 jigarzon

Any news on this one? 😄

fellenabmb avatar Mar 31 '23 19:03 fellenabmb

Any news on this?

H-pun avatar Jun 18 '23 08:06 H-pun

Hello everyone, sorry for not being able to close this PR. A lot of things has changed with the material design M3 and it was very difficult to find a convenient time to work on this but I'll try to work on it in the upcoming days although I can't promise anything due to life/work commitments. Sorry again for keeping this open for too long and thanks for understanding.

omneimneh avatar Sep 27 '23 10:09 omneimneh

I moved this to a new PR https://github.com/callstack/react-native-paper/pull/4102

omneimneh avatar Sep 30 '23 13:09 omneimneh