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

MultiSelect#deselectAt() doesn't deselecting the item #915

Closed
howudodat opened this issue Feb 13, 2024 · 0 comments
Closed

MultiSelect#deselectAt() doesn't deselecting the item #915

howudodat opened this issue Feb 13, 2024 · 0 comments
Assignees
Labels
bug Something isn't working version 2.x.x Version 2.x.x issues
Milestone

Comments

@howudodat
Copy link

Describe the bug
MultiSelect#deselectAt() is not actually deselecting the item. Shouldn't it also call option.getMenuItem().deselect(true); like select does?

To Reproduce
select a couple of options in a multi-select
call deselectAll()

Expected behavior
it should clear all selections

Existing code:

  protected void onOptionDeselected(SelectOption<V> option, boolean silent) {
    List<V> oldValue = getValue();
    if (nonNull(oldValue) && oldValue.contains(option.getValue())) {
      selectedOptions.remove(option);
      option.remove();
      if (!silent) {
        triggerChangeListeners(oldValue, getValue());
      }
    }
  }

Proposed Code:

@Override
  protected void onOptionDeselected(SelectOption<V> option, boolean silent) {
    List<V> oldValue = getValue();
    if (nonNull(oldValue) && oldValue.contains(option.getValue())) {
      selectedOptions.remove(option);
      option.remove();
	  
	  this.optionsMenu.withPauseSelectionListenersToggle(
        true,
        field -> {
          option.getMenuItem().deselect(true);
        });

      if (!silent) {
        triggerChangeListeners(oldValue, getValue());
      }
    }
  }
@vegegoku vegegoku self-assigned this Mar 18, 2024
@vegegoku vegegoku added bug Something isn't working version 2.x.x Version 2.x.x issues labels Mar 18, 2024
@vegegoku vegegoku added this to the 2.0.1 milestone Mar 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working version 2.x.x Version 2.x.x issues
Projects
None yet
Development

No branches or pull requests

2 participants