Skip to content

Commit

Permalink
feat: add option to auto activate element on mouse enter
Browse files Browse the repository at this point in the history
  • Loading branch information
ert78gb committed Jul 1, 2018
1 parent 96aaec5 commit 0b70a1b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ Any item can be `disabled` for prevent selection. For disable an item add the pr
| noResultsFound | string | `'No results found'` | The default text showed when a search has no results |
| size | `'small'/'default'/'large'` | `'default'` | Adding bootstrap classes: form-control-sm, input-sm, form-control-lg input-lg, btn-sm, btn-lg |
| searchCallback | `(search: string, item: INgxSelectOption) => boolean` | `null` | The callback function for custom filtering the select list |
| autoActiveOnMouseEnter | boolean | true | Automatically activate item when mouse enter on it |
| Output | Description |
| ------------- | ------------- |
Expand Down
3 changes: 2 additions & 1 deletion src/app/lib/ngx-select/ngx-select.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export class NgxSelectComponent implements INgxSelectOptions, ControlValueAccess
@Input() public noResultsFound = 'No results found';
@Input() public size: 'small' | 'default' | 'large' = 'default';
@Input() public searchCallback: (search: string, item: INgxSelectOption) => boolean;
@Input() public autoActiveOnMouseEnter = true;
public keyCodeToRemoveSelected = 'Delete';
public keyCodeToOptionsOpen = 'Enter';
public keyCodeToOptionsClose = 'Escape';
Expand Down Expand Up @@ -441,7 +442,7 @@ export class NgxSelectComponent implements INgxSelectOptions, ControlValueAccess

/** @internal */
public optionActivate(navigated: INgxOptionNavigated): void {
if ((this.optionActive !== navigated.activeOption) &&
if (this.autoActiveOnMouseEnter && (this.optionActive !== navigated.activeOption) &&
(!navigated.activeOption || !navigated.activeOption.disabled)) {
this.optionActive = navigated.activeOption;
this.navigated.emit(navigated);
Expand Down

0 comments on commit 0b70a1b

Please sign in to comment.