Skip to content

Commit

Permalink
fix(component): fix circular call for methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Ilya authored and Ilya committed Mar 29, 2019
1 parent 3f892e0 commit 03053bd
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 10 deletions.
2 changes: 1 addition & 1 deletion gh-pages-src/pages/dev/Example5.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
v-model="selected"
:items="items"
:error-message="errorMessage"
:successful="!errorMessage && selected"
:successful="!!(!errorMessage && selected)"
:disabled="disabled"
:readonly="readonly"
:disable-search="disableSearch"
Expand Down
10 changes: 5 additions & 5 deletions src/component.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
@keydown.enter="onEnter"
@keydown.tab.esc="setBlured"
@mousedown="onClick"
@focus="onFocus"
@focus="setFocused"
>
<div class="IZ-select__input-wrap">
<slot
Expand Down Expand Up @@ -56,7 +56,7 @@
@keyup="onSearchKeyUp"
@keydown="onSearchKeyDown"
@input="onSearch"
@focus="onFocus"
@focus="setFocused(true)"
>

<slot
Expand Down Expand Up @@ -237,11 +237,11 @@ export default {
setInputFocused () {
this.$refs['IZ-select__input-for-text'].focus()
},
setFocused () {
setFocused (byInput = false) {
if (this.focused || this.disabled || this.readonly) return
// if search enabled
if (!this.disableSearch) {
if (!this.disableSearch && !byInput) {
// focus text input
this.setInputFocused()
}
Expand All @@ -253,7 +253,7 @@ export default {
// block: this.isMobile ? 'start' : 'end'
// })
if (this.allowMobileScroll && this.isMobile) {
if (window.scrollTo && this.allowMobileScroll && this.isMobile) {
const { top } = getOffsetSum(this.$refs['IZ-select__input'])
// scroll to component input el
Expand Down
4 changes: 0 additions & 4 deletions src/eventsListeners.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { scrollIfNeeded } from '~/helpers'

export default {
onFocus () {
this.setFocused()
},
onSelectByArrow (e) {
e.preventDefault()

Expand Down Expand Up @@ -85,7 +82,6 @@ export default {
if (this.disabled || this.readonly) return

this.setFocused()
this.showMenu()
},
// on click on item
onClickSelectItem (item) {
Expand Down
1 change: 1 addition & 0 deletions tests/unit/eventsListeners.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ describe('eventsListeners', () => {

wrapper.vm.onClick()

expect(wrapper.vm.wishShowMenu).toBeTruthy()
expect(wrapper.vm.hasMenu).toBeTruthy()

const selectMenu = wrapper.find({
Expand Down

0 comments on commit 03053bd

Please sign in to comment.