refs #352 Start suggest after user stop writing

This commit is contained in:
AkiraFukushima 2018-08-08 01:05:14 +09:00
parent 9fe41145ba
commit c491b473a1
1 changed files with 10 additions and 1 deletions

View File

@ -5,7 +5,7 @@
ref="status"
v-shortkey="openSuggest ? {up: ['arrowup'], down: ['arrowdown'], enter: ['enter']} : {linux: ['ctrl', 'enter'], mac: ['meta', 'enter']}"
@shortkey="handleKey"
v-on:input="suggestAccount"
v-on:input="startSuggest"
placeholder="What is on your mind?"
autofocus>
</textarea>
@ -77,6 +77,15 @@ export default {
}
},
methods: {
startSuggest (e) {
const currentValue = e.target.value
// Start suggest after user stop writing
setTimeout(() => {
if (currentValue === this.status) {
this.suggestAccount(e)
}
}, 500)
},
async suggestAccount (e) {
// e.target.sectionStart: Cursor position
// e.target.value: current value of the textarea