ionic-selectable icon indicating copy to clipboard operation
ionic-selectable copied to clipboard

If the selected item has an item value that is null then it is not shown

Open SergeyCherman opened this issue 4 years ago • 9 comments

Issue: If items contain an item value that is null and that is the selected item, it is not being shown on load as the selected item.

Expected Behavior: If an item exists with the itemValueField as null it should be shown as selected if that is the form control/models value.

Reproduction: 2 ports exist: Tokai with id null and Vladivostok with id false. the boolean works fine, but setting the currently selected port as null does not show "Tokai".

https://stackblitz.com/edit/ionic-selectable-initial-value-dhwpws?file=pages/home/home.ts

SergeyCherman avatar May 24 '21 14:05 SergeyCherman

What version of ionic-selectable are you using?

edy-ap avatar May 28 '21 17:05 edy-ap

4.9 on my local env.

SergeyCherman avatar May 28 '21 17:05 SergeyCherman

Hi, actually null is not considered a value, therefore is not appropriate for use in ids

edy-ap avatar May 28 '21 17:05 edy-ap

Thanks! Would this be a reasonable feature request? If not we should add it to the docs.

SergeyCherman avatar May 28 '21 17:05 SergeyCherman

thanks for you contribution, let me evaluate if is reasonable add this condition for ids

edy-ap avatar May 28 '21 17:05 edy-ap

or you can submit a PR and we will evaluate the convenience to integrate it, thanks

edy-ap avatar May 28 '21 17:05 edy-ap

Sure! Can you point me to the area of the code that handles values to get me started?

SergeyCherman avatar May 28 '21 17:05 SergeyCherman

You can check the setValue method, here https://github.com/ionic-selectable/ionic-selectable/blob/1d149bf14d8cb0a991eb360dd2be622e2e6af254/packages/core/src/components/ionic-selectable/ionic-selectable.component.tsx#L1296

edy-ap avatar May 28 '21 17:05 edy-ap

Thanks! Will see if I can get a PR out shortly.

SergeyCherman avatar May 28 '21 17:05 SergeyCherman