Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

204
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda