Skip to content

Commit

Permalink
fix(chip-filter.component.html): Use variable to determine if text bo…
Browse files Browse the repository at this point in the history
…x is selected
  • Loading branch information
cbuttaro1 committed Dec 20, 2022
1 parent c1aabbe commit 7865c8d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/app/modules/chip-filter/chip-filter.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
class="multiselect-item-checkbox"
>
<div *ngIf="isLast">{{loadFilterList(filterItems)}}
<div *ngIf="focusItem == 2" aria-live="polite" style="overflow:hidden; height:0;width:0;">
<div *ngIf="focusItem == this.searchItem" aria-live="polite" style="overflow:hidden; height:0;width:0;">
{{filterItems.length}} providers found, use arrow keys to scroll through providers
</div>
</div>
Expand Down
12 changes: 6 additions & 6 deletions src/app/modules/chip-filter/chip-filter.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ export class AppChipFilterComponent implements ControlValueAccessor, OnInit, OnC
*/
public static readonly itemOffset = 3;
public static readonly selectAllItem = 1;
public static readonly searchItem = 2;
public _sourceDataType = null;
public _sourceDataFields: string[] = [];
public selectedItems: ListItem[] = [];
Expand Down Expand Up @@ -83,6 +82,7 @@ export class AppChipFilterComponent implements ControlValueAccessor, OnInit, OnC
private searchQueryChanged: Subject<string> = new Subject<string>();
public searchFilter: string;
public focusItem = 0;
public readonly searchItem = 2;

@Input() disabled = false;

Expand Down Expand Up @@ -165,7 +165,7 @@ export class AppChipFilterComponent implements ControlValueAccessor, OnInit, OnC
}

onFilterTextChange($event) {
this.focusItem = AppChipFilterComponent.searchItem;
this.focusItem = this.searchItem;
this.searchFilter = $event;
this.searchQueryChanged.next($event);
}
Expand Down Expand Up @@ -395,7 +395,7 @@ export class AppChipFilterComponent implements ControlValueAccessor, OnInit, OnC
if (!this.settings.defaultOpen) {
this.toggleDropdown(e);
// If we are including 'Select All' start there, otherwise start with the search text box.
this.focusItem = document.getElementById('selectAll') ? AppChipFilterComponent.selectAllItem : AppChipFilterComponent.searchItem;
this.focusItem = document.getElementById('selectAll') ? AppChipFilterComponent.selectAllItem : this.searchItem;
this.scrollToItem();
} else {
this.closeDropdown();
Expand All @@ -418,7 +418,7 @@ export class AppChipFilterComponent implements ControlValueAccessor, OnInit, OnC
onArrowUp(e) {
if (this.settings.defaultOpen) {
e.preventDefault();
const firstItem = document.getElementById('selectAll') ? AppChipFilterComponent.selectAllItem : AppChipFilterComponent.searchItem;
const firstItem = document.getElementById('selectAll') ? AppChipFilterComponent.selectAllItem : this.searchItem;
if (this.focusItem > firstItem) {
this.focusItem--;
this.scrollToItem();
Expand All @@ -431,7 +431,7 @@ export class AppChipFilterComponent implements ControlValueAccessor, OnInit, OnC
setTimeout(() => {
document.getElementById('selectAll').focus();
});
} else if (this.focusItem === AppChipFilterComponent.searchItem) {
} else if (this.focusItem === this.searchItem) {
setTimeout(() => {
document.getElementById('search').focus();
});
Expand All @@ -450,7 +450,7 @@ export class AppChipFilterComponent implements ControlValueAccessor, OnInit, OnC
}

selectOnSpace(e) {
if (this.focusItem !== AppChipFilterComponent.searchItem && this.settings.defaultOpen) {
if (this.focusItem !== this.searchItem && this.settings.defaultOpen) {
e.preventDefault();
if (this.focusItem === AppChipFilterComponent.selectAllItem) {
this.toggleSelectAll();
Expand Down

0 comments on commit 7865c8d

Please sign in to comment.