gcanti / tcomb-form

Forms library for react
https://gcanti.github.io/tcomb-form
MIT License
1.16k stars 136 forks source link

How to reproduce a bug on codepen? #286

Closed dearlordylord closed 8 years ago

dearlordylord commented 8 years ago

Hey @gcanti ,

it seems I found a bug with mobiles (form field value is cleared after focus on another field on mobile Safari and supposedly mobile Chrome) but I want to first reproduce it. I tried to build your library to include it as external from s3 on codepen.io but have trouble with it right now. Could you share how you build it? (webpack config or something like this?)

Thanks

gcanti commented 8 years ago

Usually I don't build it. I use npm, import it in my projects and then build the app bundle. What do you need for codepen.io? a global window.TcombForm?

dearlordylord commented 8 years ago

Better is to have t and according t.form (so I can have t.form.Form component and define a test model).

If it isn't easy I can just build standalone app and deploy it somewhere on s3 but codepen would be far more convenient for this purpose.

gcanti commented 8 years ago

Hi @Firfi,

I think I've a solution: just released v0.8.1 with a dist folder for npmcdn

Configuration for codepen:

CSS

JS

JavaScript Preprocessor: Babel

Example

http://codepen.io/anon/pen/JGMLEv

dearlordylord commented 8 years ago

Hey @gcanti , thanks a lot. I feel little uncomfortably as I resolved this issue in 15 minutes before you posted this answer. Anyways, I'll use your solution later when will meet any other issue.

My particular problem was in parent component rerender: I had a form state in child component and it was flushed every parent component rerender. Moreover, this parent component rerendered every time screen was scrolled as I have onScroll listener with setState() inside. It seems that mobile devices triggered onScroll even on onBlur for form, or just on tap so form was clearing itself.

(as a solution I just added PureRenderMixin in parent component as setState inside scroll event was setting just a boolean value)

gcanti commented 8 years ago

No problem! Now I have standard way to share tcomb-form examples ;)