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

Items removal upon tapping does not work. #19

Closed
nxr836 opened this issue Feb 24, 2021 · 5 comments
Closed

Items removal upon tapping does not work. #19

nxr836 opened this issue Feb 24, 2021 · 5 comments

Comments

@nxr836
Copy link

nxr836 commented Feb 24, 2021

MultiSelectDialogField, some initial values are provided. In the MultiSelectChipDisplay's onTap method, the removal is wrapped with setstate (this does slow down the UI refreshment).

Upon clicking on initial items, they are not removed, but the validator complains 'no items selected'.

But, if no initial values provided, it works perfectly.

@madhan-asmb
Copy link

madhan-asmb commented Mar 1, 2021

// setting the _selectedAnimals3 to desired pre-selected values list in initState - recommended
MultiSelectBottomSheetField(
    onConfirm: (values) {
        _selectedAnimals3 = values;
    },
    items: _items,
    initialValue: _selectedAnimals3,
    chipDisplay: MultiSelectChipDisplay(
        onTap: (item) {
            _selectedAnimals3.remove(item);
            return _selectedAnimals3;
        },
    ),
),

Try this code

add the return statement in onTap

@nxr836
Copy link
Author

nxr836 commented Mar 2, 2021

// setting the _selectedAnimals3 to desired pre-selected values list in initState - recommended
MultiSelectBottomSheetField(
    onConfirm: (values) {
        _selectedAnimals3 = values;
    },
    items: _items,
    initialValue: _selectedAnimals3,
    chipDisplay: MultiSelectChipDisplay(
        onTap: (item) {
            _selectedAnimals3.remove(item);
            return _selectedAnimals3;
        },
    ),
),

Try this code

add the return statement in onTap

Wow! It works, it seems the last 'return' did the job. Thanks bro! But how did you figure it out?

@madhan-asmb
Copy link

Check out this #11 issue, you will get to know how I figured out

@CHB61
Copy link
Owner

CHB61 commented Mar 7, 2021

@madhan-asmb Thanks :)

Going to drop a link to the first issue regarding this type of problem which provides more background.

Issue #5 Initial value not working as expected

@CHB61 CHB61 closed this as completed Mar 7, 2021
@ronytesler
Copy link

Spent hours before getting here, maybe a better documentation could help.

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