Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

205
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda