mirror of
https://github.com/flarum/core.git
synced 2025-08-03 23:17:43 +02:00
Fix cursor not being placed correctly after mention insertion
This commit is contained in:
@@ -28,10 +28,12 @@ export default function addComposerAutocomplete() {
|
|||||||
const applySuggestion = function(replacement) {
|
const applySuggestion = function(replacement) {
|
||||||
const insert = replacement + ' ';
|
const insert = replacement + ' ';
|
||||||
|
|
||||||
|
// When calling setValue(), mentionStart will be set back to 0 so we need to compute this beforehand
|
||||||
|
const index = mentionStart - 1 + insert.length;
|
||||||
|
|
||||||
const content = composer.content();
|
const content = composer.content();
|
||||||
composer.editor.setValue(content.substring(0, mentionStart - 1) + insert + content.substr($textarea[0].selectionStart));
|
composer.editor.setValue(content.substring(0, mentionStart - 1) + insert + content.substr($textarea[0].selectionStart));
|
||||||
|
|
||||||
const index = mentionStart - 1 + insert.length;
|
|
||||||
composer.editor.setSelectionRange(index, index);
|
composer.editor.setSelectionRange(index, index);
|
||||||
|
|
||||||
dropdown.hide();
|
dropdown.hide();
|
||||||
|
Reference in New Issue
Block a user