Skip to content
This repository has been archived by the owner on Feb 13, 2024. It is now read-only.

Commit

Permalink
Fixed selection multiple tags issue (win), closes #2494
Browse files Browse the repository at this point in the history
  • Loading branch information
IndrekV committed Jun 25, 2018
1 parent e2d6257 commit 2ba5d4f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@ public void SetController(AutoCompleteController controller)
{
this.controller = controller;
this.needsToRefreshList = true;
if (this.popup.IsOpen)
this.ensureList();
}

public void OpenAndShowAll()
Expand Down Expand Up @@ -273,7 +275,7 @@ private void textboxOnPreviewKeyDown(object sender, KeyEventArgs e)
{
if (this.IsOpen)
{
if (this.confirmCompletion())
if (this.confirmCompletion(true))
{
e.Handled = true;
}
Expand Down Expand Up @@ -321,14 +323,14 @@ private void updateDropDownButton(object sender, EventArgs e)

#endregion

private bool confirmCompletion()
private bool confirmCompletion(bool withKeyboard)
{
var item = this.controller.SelectedItem;
if (item == null)
{
return false;
}
this.select(item, true);
this.select(item, withKeyboard);
return true;
}

Expand Down Expand Up @@ -446,8 +448,25 @@ private void listBox_PreviewMouseDown(object sender, MouseButtonEventArgs e)
if (dep == null)
return;

listBox.SelectedIndex = listBox.ItemContainerGenerator.IndexFromContainer(dep);
this.confirmCompletion();
int index = listBox.ItemContainerGenerator.IndexFromContainer(dep);
listBox.SelectedIndex = index;

this.confirmCompletion(false);

// Remove selected item from list if tags autocomplete
if (this.controller.autocompleteType == 1)
{
IEditableCollectionView items = listBox.Items; //Cast to interface
if (items.CanRemove)
{
items.RemoveAt(index);
}
}
}

internal bool popUpOpen()
{
return this.popup.IsOpen;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@ private bool tryRemoveLastTag()

public void SetKnownTags(IEnumerable<string> tags)
{
this.autoComplete.SetController(AutoCompleteControllers.ForTags(tags, this.Contains));
if (!this.autoComplete.popUpOpen())
this.autoComplete.SetController(AutoCompleteControllers.ForTags(tags, this.Contains));
}

public bool Contains(string tag)
Expand Down

0 comments on commit 2ba5d4f

Please sign in to comment.