Giter Site home page Giter Site logo

Comments (12)

alvaromb avatar alvaromb commented on September 7, 2024 7

It could be handled by tcomb-form-native, enabled or disabled by a prop in the Form component. This is something we would like to have, how do you feel about sending a PR? I'm glad to review.

from tcomb-form-native.

yosiat avatar yosiat commented on September 7, 2024 5

@gcanti the solution in SO is very specific to specific form.
I would expect tcomb-form-native to handle this dynamically.

from tcomb-form-native.

leonapse avatar leonapse commented on September 7, 2024 4

Any update on this?

from tcomb-form-native.

marcello3d avatar marcello3d commented on September 7, 2024 1

Was this issue closed because of no gist or because the feature was added?

Here is an example of how to do it: http://stackoverflow.com/questions/32748718/react-native-how-to-select-the-next-textinput-after-pressing-the-next-keyboar

In short, add an onSubmitEditing attribute to the TextInput:

<TextInput 
...
  onSubmitEditing={(event) => { 
    this.refs.foo.focus(); 
  }}
/>

from tcomb-form-native.

dsuarezv avatar dsuarezv commented on September 7, 2024 1

I agree it'd be nice to have this inside tcomb-form-native. Just wanted to leave a possible workaround for anyone coming to this issue (like I did). Add this method to the component with the form:

addNext = (nextFieldName) => {
        return {
            returnKeyType: 'next',
            onSubmitEditing: () => { 
                // Assuming your form ref is stored in this.form, change to your needs. 
                const target = this.form.getComponent(nextFieldName);
                if (target && target.refs && target.refs.input) target.refs.input.focus();
            }
        }
    }

and then in the config of your fields simply add

fields: {
    name: { label: 'Name', ...this.addNext('surname') },
    surname: { label: 'Surname', ...this.addNext('address') },
   
}

from tcomb-form-native.

alina-beck avatar alina-beck commented on September 7, 2024 1

I know this is an old topic – but this is still an issue!

I can't use the solution above because onSubmitEditing is not fired when hitting the next button on Android. Tried with onBlur instead, which is fired, but then target.refs is just an empty object, so I cannot focus the next input. Any advice on how to solve this?

Here is the simplified code:

const formRef = useRef();

const Name = t.struct({
    firstname: t.String,
    lastname: t.String,
});

const options = {
    order: ['firstname', 'lastname'],
    fields: {
        firstname: {
            placeholder: 'First Name',
            returnKeyType: 'next',
            onSubmitEditing: () => console.log('submit editing'), // never fired
            onBlur: () => formRef.current.getComponent('lastname').refs.input.focus(), // input is undefined
        },
        lastname: {
            placeholder: 'Last Name',
            returnKeyType: 'done',
        },
    },
};

return (
    <KeyboardAvoidingView behavior='position'>
        <Animatable.View animation='fadeInUp' duration={400}>
            <Form ref={formRef} type={Name} options={options} value={formData} onChange={handleFormChange} />
        </Animatable.View>
    <KeyboardAvoidingView>
);

from tcomb-form-native.

gcanti avatar gcanti commented on September 7, 2024

Yes, it would be nice.
Generally if it can be done by hand and a rule exists, it can be automated by tcomb-form(-native).
Currently how you do that with react-native? Could you provide a gist?

from tcomb-form-native.

gcanti avatar gcanti commented on September 7, 2024

Was this issue closed because...

Because of inactivity. BTW there's a solution for tcomb-form-native in the SO question you posted and that links to this issue #96 (no feature to add)

from tcomb-form-native.

marcello3d avatar marcello3d commented on September 7, 2024

Excellent. Wasn't familiar with the getComponent api.

from tcomb-form-native.

AlanFoster avatar AlanFoster commented on September 7, 2024

This would be cool functionality to have; Is this something that tcomb-form-native should handle out of the box, or is that up to the user to control? 🤔

from tcomb-form-native.

quantumpotato avatar quantumpotato commented on September 7, 2024

+1, subscribing to thread

from tcomb-form-native.

vanko0309 avatar vanko0309 commented on September 7, 2024

I know this is an old topic – but this is still an issue!

I can't use the solution above because onSubmitEditing is not fired when hitting the next button on Android. Tried with onBlur instead, which is fired, but then target.refs is just an empty object, so I cannot focus the next input. Any advice on how to solve this?

Here is the simplified code:

const formRef = useRef();

const Name = t.struct({
    firstname: t.String,
    lastname: t.String,
});

const options = {
    order: ['firstname', 'lastname'],
    fields: {
        firstname: {
            placeholder: 'First Name',
            returnKeyType: 'next',
            onSubmitEditing: () => console.log('submit editing'), // never fired
            onBlur: () => formRef.current.getComponent('lastname').refs.input.focus(), // input is undefined
        },
        lastname: {
            placeholder: 'Last Name',
            returnKeyType: 'done',
        },
    },
};

return (
    <KeyboardAvoidingView behavior='position'>
        <Animatable.View animation='fadeInUp' duration={400}>
            <Form ref={formRef} type={Name} options={options} value={formData} onChange={handleFormChange} />
        </Animatable.View>
    <KeyboardAvoidingView>
);

Any luck on this?

from tcomb-form-native.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.