Skip to content

Commit 0251734

Browse files
committed
Update utils.js
1 parent 63369ca commit 0251734

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

utils.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -724,6 +724,26 @@ Element.prototype.on = (events, callback, passive) => {
724724
}
725725

726726

727+
// focus cursor to end of element
728+
let focusCursorToEnd = (el) => {
729+
730+
// focus element
731+
el.focus();
732+
733+
const nodes = el.childNodes;
734+
735+
// if child nodes exist
736+
if (nodes.length !== 0) {
737+
738+
// move cursor to end of input
739+
const s = window.getSelection();
740+
s.setBaseAndExtent(nodes[0], nodes[0].length, nodes[0], nodes[0].length);
741+
742+
}
743+
744+
}
745+
746+
727747
// copy
728748
let copy = async (text) => {
729749

0 commit comments

Comments
 (0)