Git Product home page Git Product logo

Comments (4)

gaperton avatar gaperton commented on September 4, 2024

Create your own <Input /> tag which behaves like this. This is the normal way of handling such a situation in the way needed for you.

For the start copy Input implementation from tags.jsx. Then change the way how it handles the validation error which is enclosed in the link. There is no magic at all, the creation of your own controls is straightforward:

https://github.com/Volicon/NestedLink/blob/master/tags.jsx#L35

Your Input must know whenever it's focused or touched and suppress displaying the validation error if it's not. Probably, you will need to add the local state to it to make it remember such a thing.

from nestedlink.

gaperton avatar gaperton commented on September 4, 2024

You're supposed to create your own controls wrapping all necessary styles and handling error formatting, in the way that your forms will be defined with the semantic markup. That's an overall idea and links makes it practically possible. tags.jsx is just an example and the starting boilerplate.

That's how it is done in userslist example:

const ValidatedInput = ( props ) => (
    <div>
        <Input { ...props } />
        <div className="validation-error">
            { props.valueLink.error || '' }
        </div>
    </div>
);

https://github.com/Volicon/NestedLink/blob/master/example/src/userslist.jsx#L150

You need to do the same thing but use raw <input/> and add the local state to make it remember whenever it was touched. That's it.

from nestedlink.

ckpinguin avatar ckpinguin commented on September 4, 2024

OK, thanks I'll try it :-)
Yesterday I „solved“ it using onBlur={() => this.setState({titleTouched: true})} but having more local state in a subcomponent did not feel right.

from nestedlink.

gaperton avatar gaperton commented on September 4, 2024

Yesterday I „solved“ it using onBlur={() => this.setState({titleTouched: true})} but having more local state in a subcomponent did not feel right.

It is okay. You need to hide this local state in <Input/> itself once and forget about it. This state is entirely private and there is no reason to expose it outside.

from nestedlink.

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.