Revert "Merge branch 'hotfix/issues-in-autocomplete' into 'develop'"

This reverts merge request !574
This commit is contained in:
HJ 2019-02-14 19:05:59 +00:00
parent 295becd6c8
commit ee4c6f362b
2 changed files with 21 additions and 19 deletions

View File

@ -24,7 +24,8 @@ const AutoCompleteInput = {
data () {
return {
caret: 0,
highlighted: 0
highlighted: 0,
text: this.value
}
},
computed: {
@ -41,7 +42,7 @@ const AutoCompleteInput = {
return (this.wordAtCaret || {}).word || ''
},
wordAtCaret () {
const word = Completion.wordAtPosition(this.value, this.caret - 1) || {}
const word = Completion.wordAtPosition(this.text, this.caret - 1) || {}
return word
},
candidates () {
@ -112,8 +113,8 @@ const AutoCompleteInput = {
}
},
replace (replacement) {
this.$emit('input', Completion.replaceWord(this.value, this.wordAtCaret, replacement))
const el = this.$el.querySelector('textarea') || this.$el.querySelector('input')
this.text = Completion.replaceWord(this.text, this.wordAtCaret, replacement)
const el = this.$el.querySelector('textarea')
el.focus()
this.caret = 0
},
@ -124,7 +125,8 @@ const AutoCompleteInput = {
e.preventDefault()
const candidate = this.candidates[this.highlighted]
const replacement = candidate.utf || (candidate.screen_name + ' ')
this.$emit('input', Completion.replaceWord(this.value, this.wordAtCaret, replacement))
this.text = Completion.replaceWord(this.text, this.wordAtCaret, replacement)
this.$emit('input', this.text)
const el = this.$el.querySelector('textarea') || this.$el.querySelector('input')
el.focus()
this.caret = 0

View File

@ -4,8 +4,8 @@
v-if="multiline"
ref="textarea"
rows="1"
:value="value" :class="classObj" :id="id" :placeholder="placeholder"
@input="$emit('input', $event.target.value), autoResize && resize($event)"
:value="text" :class="classObj" :id="id" :placeholder="placeholder"
@input="text = $event.target.value, $emit('input', $event.target.value), autoResize && resize($event)"
@click="setCaret"
@keyup="setCaret"
@keydown.down="cycleForward"
@ -13,17 +13,17 @@
@keydown.shift.tab="cycleBackward"
@keydown.tab="cycleForward"
@keydown.enter="replaceCandidate"
@drop="drop && drop($event)"
@dragover.prevent="dragoverPrevent && dragoverPrevent($event)"
@paste="paste && paste($event)"
@keydown.meta.enter="keydownMetaEnter && keydownMetaEnter($event)"
@keyup.ctrl.enter="keyupCtrlEnter && keyupCtrlEnter($event)">
@drop="drop && drop()"
@dragover.prevent="dragoverPrevent && dragoverPrevent()"
@paste="paste && paste()"
@keydown.meta.enter="keydownMetaEnter && keydownMetaEnter()"
@keyup.ctrl.enter="keyupCtrlEnter && keyupCtrlEnter()">
</textarea>
<input
v-else
ref="textarea"
:value="value" :class="classObj" :id="id" :placeholder="placeholder"
@input="$emit('input', $event.target.value), autoResize && resize($event)"
:value="text" :class="classObj" :id="id" :placeholder="placeholder"
@input="text = $event.target.value, $emit('input', $event.target.value), autoResize && resize($event)"
@click="setCaret"
@keyup="setCaret"
@keydown.down="cycleForward"
@ -31,11 +31,11 @@
@keydown.shift.tab="cycleBackward"
@keydown.tab="cycleForward"
@keydown.enter="replaceCandidate"
@drop="drop && drop($event)"
@dragover.prevent="dragoverPrevent && dragoverPrevent($event)"
@paste="paste && paste($event)"
@keydown.meta.enter="keydownMetaEnter && keydownMetaEnter($event)"
@keyup.ctrl.enter="keyupCtrlEnter && keyupCtrlEnter($event)"/>
@drop="drop && drop()"
@dragover.prevent="dragoverPrevent && dragoverPrevent()"
@paste="paste && paste()"
@keydown.meta.enter="keydownMetaEnter && keydownMetaEnter()"
@keyup.ctrl.enter="keyupCtrlEnter && keyupCtrlEnter()"/>
<div style="position:relative;" v-if="candidates">
<div class="autocomplete-panel">
<div v-for="candidate in candidates" @click="replace(candidate.utf || (candidate.screen_name + ' '))">