fix(client): fix varaible textarea setRange bug (#2862)
This commit is contained in:
parent
0e9ab35254
commit
9cbae661b1
@ -229,6 +229,7 @@ export function TextArea(props) {
|
|||||||
const sel = window.getSelection?.();
|
const sel = window.getSelection?.();
|
||||||
if (sel) {
|
if (sel) {
|
||||||
const children = Array.from(current.childNodes) as HTMLElement[];
|
const children = Array.from(current.childNodes) as HTMLElement[];
|
||||||
|
if (children.length) {
|
||||||
if (range[0] === -1) {
|
if (range[0] === -1) {
|
||||||
if (range[1]) {
|
if (range[1]) {
|
||||||
nextRange.setStartAfter(children[range[1] - 1]);
|
nextRange.setStartAfter(children[range[1] - 1]);
|
||||||
@ -243,6 +244,7 @@ export function TextArea(props) {
|
|||||||
} else {
|
} else {
|
||||||
nextRange.setEnd(children[range[2]], range[3]);
|
nextRange.setEnd(children[range[2]], range[3]);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
nextRange.collapse(true);
|
nextRange.collapse(true);
|
||||||
sel.removeAllRanges();
|
sel.removeAllRanges();
|
||||||
sel.addRange(nextRange);
|
sel.addRange(nextRange);
|
||||||
|
Loading…
Reference in New Issue
Block a user