From: Dessalines Date: Mon, 14 Feb 2022 19:43:07 +0000 (-0500) Subject: Smart select inner content after bold or italics. Fixes #497 (#577) X-Git-Url: http://these/git/%7B%60https:/static/git-favicon.png?a=commitdiff_plain;h=99f652422f7d3a25490ef938f0f85cce48d121ce;p=lemmy-ui.git Smart select inner content after bold or italics. Fixes #497 (#577) --- diff --git a/src/shared/components/common/markdown-textarea.tsx b/src/shared/components/common/markdown-textarea.tsx index 5b1c8ee..381ecb4 100644 --- a/src/shared/components/common/markdown-textarea.tsx +++ b/src/shared/components/common/markdown-textarea.tsx @@ -459,6 +459,21 @@ export class MarkdownTextArea extends Component< } this.contentChange(); this.setState(this.state); + + textarea.focus(); + + if (start !== end) { + textarea.setSelectionRange( + start + beforeChars.length, + end + afterChars.length + ); + } else { + textarea.setSelectionRange( + start + beforeChars.length, + end + emptyChars.length + afterChars.length + ); + } + setTimeout(() => { autosize.update(textarea); }, 10);