🌐 AI搜索 & 代理 主页
Skip to content

Commit 008198b

Browse files
Merge branch 'ag/5947' of https://github.com/andrei-gheorghiu/bootstrap-vue into ag/5947
2 parents 6e5c78c + bf74818 commit 008198b

File tree

2 files changed

+23
-24
lines changed

2 files changed

+23
-24
lines changed

src/components/form-tags/form-tags.js

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,14 @@
22
// Based loosely on https://adamwathan.me/renderless-components-in-vuejs/
33
import { Vue } from '../../vue'
44
import { NAME_FORM_TAGS } from '../../constants/components'
5-
import { EVENT_NAME_TAG_STATE, EVENT_OPTIONS_PASSIVE } from '../../constants/events'
5+
import {
6+
EVENT_NAME_BLUR,
7+
EVENT_NAME_FOCUS,
8+
EVENT_NAME_FOCUSIN,
9+
EVENT_NAME_FOCUSOUT,
10+
EVENT_NAME_TAG_STATE,
11+
EVENT_OPTIONS_PASSIVE
12+
} from '../../constants/events'
613
import { CODE_BACKSPACE, CODE_DELETE, CODE_ENTER } from '../../constants/key-codes'
714
import {
815
PROP_TYPE_ARRAY,
@@ -24,7 +31,7 @@ import { identity } from '../../utils/identity'
2431
import { isEvent, isNumber, isString } from '../../utils/inspect'
2532
import { looseEqual } from '../../utils/loose-equal'
2633
import { makeModelMixin } from '../../utils/model'
27-
import { pick, sortKeys } from '../../utils/object'
34+
import { omit, pick, sortKeys } from '../../utils/object'
2835
import { hasPropFunction, makeProp, makePropsConfigurable } from '../../utils/props'
2936
import { escapeRegExp, toString, trim, trimLeft } from '../../utils/string'
3037
import { formControlMixin, props as formControlProps } from '../../mixins/form-control'
@@ -181,18 +188,13 @@ export const BFormTags = /*#__PURE__*/ Vue.extend({
181188
},
182189
computedInputHandlers() {
183190
return {
184-
...pick(
185-
this.bvListeners,
186-
Object.keys(this.bvListeners).filter(
187-
key => !['focus', 'blur', 'focusin', 'focusout'].includes(key)
188-
)
189-
),
190-
input: this.onInputInput,
191+
...omit(this.bvListeners, [EVENT_NAME_FOCUSIN, EVENT_NAME_FOCUSOUT]),
192+
blur: this.onInputBlur,
191193
change: this.onInputChange,
192-
keydown: this.onInputKeydown,
193-
reset: this.reset,
194194
focus: this.onInputFocus,
195-
blur: this.onInputBlur
195+
input: this.onInputInput,
196+
keydown: this.onInputKeydown,
197+
reset: this.reset
196198
}
197199
},
198200
computedSeparator() {
@@ -420,42 +422,38 @@ export const BFormTags = /*#__PURE__*/ Vue.extend({
420422
}
421423
},
422424
onInputFocus(event) {
423-
if (typeof this.bvListeners.focus === 'function' && this.focusState !== 'out') {
425+
if (this.focusState !== 'out') {
424426
this.focusState = 'in'
425427
this.$nextTick(() => {
426428
requestAF(() => {
427429
if (this.hasFocus) {
428-
this.bvListeners.focus(event)
430+
this.$emit(EVENT_NAME_FOCUS, event)
429431
this.focusState = null
430432
}
431433
})
432434
})
433435
}
434436
},
435437
onInputBlur(event) {
436-
if (typeof this.bvListeners.blur === 'function' && this.focusState !== 'in') {
438+
if (this.focusState !== 'in') {
437439
this.focusState = 'out'
438440
this.$nextTick(() => {
439441
requestAF(() => {
440442
if (!this.hasFocus) {
441-
this.bvListeners.blur(event)
443+
this.$emit(EVENT_NAME_BLUR, event)
442444
this.focusState = null
443445
}
444446
})
445447
})
446448
}
447449
},
448-
onFocusin(e) {
450+
onFocusin(event) {
449451
this.hasFocus = true
450-
if (typeof this.bvListeners.focusin === 'function') {
451-
this.bvListeners.focusin(e)
452-
}
452+
this.$emit(EVENT_NAME_FOCUSIN, event)
453453
},
454-
onFocusout(e) {
454+
onFocusout(event) {
455455
this.hasFocus = false
456-
if (typeof this.bvListeners.focusout === 'function') {
457-
this.bvListeners.focusout(e)
458-
}
456+
this.$emit(EVENT_NAME_FOCUSOUT, event)
459457
},
460458
handleAutofocus() {
461459
this.$nextTick(() => {

src/constants/events.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export const EVENT_NAME_ENABLE = 'enable'
1616
export const EVENT_NAME_ENABLED = 'enabled'
1717
export const EVENT_NAME_FILTERED = 'filtered'
1818
export const EVENT_NAME_FIRST = 'first'
19+
export const EVENT_NAME_FOCUS = 'focus'
1920
export const EVENT_NAME_FOCUSIN = 'focusin'
2021
export const EVENT_NAME_FOCUSOUT = 'focusout'
2122
export const EVENT_NAME_HEAD_CLICKED = 'head-clicked'

0 commit comments

Comments
 (0)