Skip to content

Can't get cursor position #77

@lcsvcn

Description

@lcsvcn

I want to get current caret position. For example, for the image below:
Screenshot 2023-06-05 at 07 57 01
I would like to get cursor position 2 (0 being the initial cursor position, if text was empty)

Normally I would achieve using something like this:

const handleOnClick = () => {
   if (inputRef.current && inputRef.current.inputRef) {
        const { selectionStart, selectionEnd } = inputRef.current.inputRef;
        console.log('Selection Start:', selectionStart);
        console.log('Selection End:', selectionEnd);
   }
 }
 <MarkedInput
        ref={inputRef}
        Mark={RemovableMark}
        value={value}
        onChange={onChange}
      />

But inputRef doesn't jave current inputRef, so I can't use selectionStart and selectionEnd.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions