Merge pull request #808 from h3poteto/iss-791
closes #791 Fix cursor position when user types arrow keys on image description
This commit is contained in:
commit
7f097067e0
|
@ -28,6 +28,8 @@
|
||||||
class="image-description"
|
class="image-description"
|
||||||
:placeholder="$t('modals.new_toot.description')"
|
:placeholder="$t('modals.new_toot.description')"
|
||||||
v-model="mediaDescriptions[media.id]"
|
v-model="mediaDescriptions[media.id]"
|
||||||
|
v-shortkey="{left: ['arrowleft'], right: ['arrowright']}"
|
||||||
|
@shortkey="handleDescriptionKey"
|
||||||
role="textbox"
|
role="textbox"
|
||||||
contenteditable="true"
|
contenteditable="true"
|
||||||
aria-multiline="true">
|
aria-multiline="true">
|
||||||
|
@ -301,6 +303,19 @@ export default {
|
||||||
})
|
})
|
||||||
.catch(_ => {})
|
.catch(_ => {})
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
handleDescriptionKey (event) {
|
||||||
|
const current = event.target.selectionStart
|
||||||
|
switch (event.srcKey) {
|
||||||
|
case 'left':
|
||||||
|
event.target.setSelectionRange(current - 1, current - 1)
|
||||||
|
break
|
||||||
|
case 'right':
|
||||||
|
event.target.setSelectionRange(current + 1, current + 1)
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
return true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue