Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

203
Views
Shifting cursor to the newly created text box

so I've a sms mesasge body which creates another segment if the charaeter goes greater than 160 but sadly the cursor is not moving to the newly created segment.`

 const [cursor, setCursor] = useState(0);


useLayoutEffect(() => {
    if (showSegmentsTabs.includes(tabType) && activeTarget) {
        activeTarget.selectionStart = cursor;
        activeTarget.selectionEnd = cursor;
    }
});

return (
                    <ActiveMessageTabComponent
                        {...props}
                        {...field}
                        onFocus={handleLastActiveField(field.name)}
                        cursor={cursor}
                        setCursor={setCursor}
                        onChange={(...params) => {
                            const [event] = params;

                            if (tabType === 'sms') {
                                const smsText = getSmsText(values, activeLanguageTab);

                                if (
                                    _.get(event, 'nativeEvent.data') &&
                                    smsText.length >= maxInputLengthConfig[tabType]
                                ) {
                                    return;
                                }
                            }

                            field.onChange(...params);

                            const input = event.target;
                            const cursor = input.selectionStart;

                            setCursor(cursor);
                        }}
                    />
                );
            }}
        </Field>
    );
};

The above code is used to render the text box and the it will be create a new sms segment based on user input I reckon, I tried adding autofocus as a property while rendering but the cursor is not moving forward, can someone help me to implemnet the cursor in a way that it moves along with the user's input.

SmsText box

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!