Choices icon indicating copy to clipboard operation
Choices copied to clipboard

When renderSelectedChoices set to 'always' for a multiple select, clicking a selected item should clear it

Open ambroseya opened this issue 4 years ago • 1 comments

Describe the bug I think it is a bug that when renderSelectedChoices set to 'always' for a multiple select, clicking a selected item selects it again instead of toggling its selected state.

To Reproduce Steps to reproduce the behavior: use renderSelectedChoices set to always for a multiple select.

Expected behavior I expect clicking an element to unselect it

Desktop (please complete the following information):

  • OS: [e.g. iOS] Windows 10
  • Browser [e.g. chrome, safari] Chrome
  • Version [e.g. 22] Latest

If you agree it's a bug I'll put in a PR. Otherwise I'll code around it for my needs.

ambroseya avatar Jul 28 '20 00:07 ambroseya

I ran into the same problem and found a workaround like this:

    @Listen('choice')
    removeAlreadySelected(e: CustomEvent) {
      if (e.detail.choice.selected && this.type === 'multiple') {
        setTimeout(() => { this.removeActiveItemsByValue(e.detail.choice.value)
        }, 100)
      }
    }

Ntuk avatar Aug 03 '20 07:08 Ntuk