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

[Android] Cannot set empty field #592

Open
maticDevelo opened this issue Nov 11, 2024 · 4 comments
Open

[Android] Cannot set empty field #592

maticDevelo opened this issue Nov 11, 2024 · 4 comments

Comments

@maticDevelo
Copy link

maticDevelo commented Nov 11, 2024

On Android devices dropdown automatically selects first item. If i dont have Picker.item Select Property it would select Item 1.
What it shoud do is if value is 0 or undefined not show a label. It should be empty field. I can achieve empty field if i set first Item label to empty string. However than in modal i have this empty block.

The ideal would be if in modal it says Select Property label so user can click on that to reset field. And then the field should be empty.

Is there a way to achieve this? The code is usuall. Picker component with item map of Picker.Items.

Screenshot 2024-11-11 at 13 55 55 Screenshot 2024-11-11 at 13 56 02 Screenshot 2024-11-11 at 14 05 09 Screenshot 2024-11-11 at 14 01 08
@dmk3141618
Copy link

Same issue on Android.

I can set empty string as a value on the iOS device.

But I can not set empty string as a value on the Android device. It does not trigger onValueChange.
value is '', 'option1', 'option2'
then '' >> 'option1' , it triggers onValueChange.
then 'option1' >> 'option2' , it triggers onValueChange.
But 'option2' >> '' , it does not trigger onValueChange.
So I can not reset value to the empty state.

on the iOS device, it works.

@dmk3141618
Copy link

Any updates? Sorry but I really need this fixed.

@jeffnian88
Copy link

Hi all,

is there any update?

@vincicat
Copy link

not a very useful update: you can't select the empty string Item because falsy value on Android will not trigger onValueChange (see #608)
in the long term, that require the contributors to fix the data type on Android; In the short term, there is a trick: you can use whitespace as the empty value placeholder.

So the "empty field" will be something like this:

<Picker.Item value=" " label="" />

and in the function that processing the selected value....

valueProcessor = (v = "")=>{ 
    v = v.trim(); // clean up: placeholder value will be a empty string now
    /* remaining tasks */ 
}

demo

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

No branches or pull requests

4 participants