Skip to content

Commit

Permalink
fix: reset selection range when selecting option with cursor (microso…
Browse files Browse the repository at this point in the history
…ft#5834)

* reset selection range when selecting option with cursor

* Change files

Co-authored-by: Chris Holt <chhol@microsoft.com>
  • Loading branch information
simonxabris and chrisdholt authored May 4, 2022
1 parent 960cfeb commit 5b82a4b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "reset selection range when selecting option with cursor",
"packageName": "@microsoft/fast-foundation",
"email": "abris96@gmail.com",
"dependentChangeType": "patch"
}
12 changes: 10 additions & 2 deletions packages/web-components/fast-foundation/src/combobox/combobox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ export class Combobox extends FormAssociatedCombobox {

this.selectedOptions = [captured];
this.control.value = captured.text;
this.clearSelectionRange();
this.updateValue(true);
}

Expand Down Expand Up @@ -433,8 +434,7 @@ export class Combobox extends FormAssociatedCombobox {
}

this.open = false;
const controlValueLength = this.control.value.length;
this.control.setSelectionRange(controlValueLength, controlValueLength);
this.clearSelectionRange();
break;
}

Expand Down Expand Up @@ -667,6 +667,14 @@ export class Combobox extends FormAssociatedCombobox {
this.$emit("change");
}
}

/**
* @internal
*/
private clearSelectionRange() {
const controlValueLength = this.control.value.length;
this.control.setSelectionRange(controlValueLength, controlValueLength);
}
}

/**
Expand Down

0 comments on commit 5b82a4b

Please sign in to comment.