refs #791 Fix cursor position when user type arrow keys on image description
This commit is contained in:
parent
abc4bf5818
commit
bd16a491fa
|
@ -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