Skip to content

Commit

Permalink
fix(combobox): keep focus while filtering and improve input on small …
Browse files Browse the repository at this point in the history
…devices

closes #106
closes #139
Signed-off-by: Ivan Donchev <idonchev@vmware.com>
  • Loading branch information
Jinnie committed Jun 6, 2022
1 parent c964b9d commit ec7d423
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion projects/angular/src/forms/combobox/_combobox.clarity.scss
Expand Up @@ -55,7 +55,7 @@
@include css-var(font-size, clr-combobox-font-size, $clr-combobox-font-size, $clr-use-custom-properties);

&.multi {
min-width: $clr-ng-multiselect-min-width;
min-width: calc(min($clr-ng-multiselect-min-width, 100%));
padding-bottom: $clr_baselineRem_0_125;
}

Expand Down
5 changes: 5 additions & 0 deletions projects/angular/src/forms/combobox/options.ts
Expand Up @@ -134,6 +134,11 @@ export class ClrOptions<T> implements AfterViewInit, LoadingListener, OnDestroy
) {
this.toggleService.open = false;
}
}),
this.items.changes.subscribe(() => {
setTimeout(() => {
this.focusHandler.focusFirstActive();
});
})
);
}
Expand Down
Expand Up @@ -201,7 +201,13 @@ export class ComboboxFocusHandler<T> {
firstActive = this.selectionService.selectionModel.model as T;
}
const activeProxy = this.optionData.find(option => option.value === firstActive);
this.pseudoFocus.select(activeProxy);
if (activeProxy) {
// active element is visible
this.pseudoFocus.select(activeProxy);
} else {
// we have active element, but it's filtered out
this.pseudoFocus.select(this.optionData[0]);
}
}
}
}
Expand Down

0 comments on commit ec7d423

Please sign in to comment.