Skip to content

Commit

Permalink
Merge pull request #76 from alexeyklenov/feature-issue-74-auto-select
Browse files Browse the repository at this point in the history
`autoSelectOnEnter` property logic
  • Loading branch information
ikloster03 authored Jun 24, 2020
2 parents 75d405a + e0d88ee commit 70bc603
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export default {
| unhighlightClassName | No | string | CSS class name applied to unhighlighted text |
| highlightTag | No | string | Type of tag to wrap around highlighted matches; defaults to `mark` but can also be a component |
| locationOptions | No | object | Location options for choosing cities or countries |
| autoSelectOnEnter | No | boolean | Select first suggestion on ENTER key press when no one suggestion is focused |


## Dependencies
Expand Down
1 change: 1 addition & 0 deletions ru/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ highlightClassName | Нет | string | Имя класса CSS, применен
unhighlightClassName | Нет | string | Имя класса CSS, примененное к невыделенному тексту
highlightTag | Нет | string | Тип тега для обертывания вокруг выделенных совпадений; по умолчанию для `mark` но также может быть компонентом
locationOptions | Нет | object | Варианты расположения для выбора городов или стран
autoSelectOnEnter | Нет | boolean | Если `true`, то при нажатии клавиши `ENTER` будет выбираться первая подсказка, если не одна из подсказок не активна

## Зависимости

Expand Down
3 changes: 3 additions & 0 deletions src/components/VueDadata.vue
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export default class VueDadata extends Vue {
suggestion: DadataSuggestion,
) => void;
@Prop(Function) public readonly validate?: (value: string) => void;
@Prop({type: Boolean, default: false}) public readonly autoSelectOnEnter?: boolean;
public inputQuery = '';
public inputFocused = false;
Expand Down Expand Up @@ -169,6 +170,8 @@ export default class VueDadata extends Vue {
event.preventDefault();
if (this.suggestionIndex >= 0) {
this.selectSuggestion(this.suggestionIndex);
} else if(this.autoSelectOnEnter && this.suggestions.length > 0){
this.selectSuggestion(0);
}
}
}
Expand Down

0 comments on commit 70bc603

Please sign in to comment.