Ant-design-vue: Form v-decorator on change debounce

Created on 3 Dec 2019  ·  3Comments  ·  Source: vueComponent/ant-design-vue

  • [x] I have searched the issues of this repository and believe that this is not a duplicate.

What problem does this feature solve?

When facing a large number of inputs in form (in my case ~40) some "typing lag" is faced. This happen because v-decorator onChange event is listening to all the inputs. So, the v-decorator performs data update (in form context) every time a character is typed, and the component re-render as expected (to perform validation etc). But when the component have a lot of inputs, it's visible how that is impact (show GIF attached or go to reproduction link). Please if i'm wrong and some solution already exists tell me, thanks!

What does the proposed API look like?

I think some "debounce" option can help with that, or the addition of new trigger option like onBlur to perform the v-decorator trigger update data/rules execution/etc and not when each char is typed. Or even another better solution =)

Reproduction link

Edit on CodeSandbox

Alt Text

Feature Request discussion

Most helpful comment

@tangjinzhou thanks for your reply! Tried your example with 'self Update' but apparently the issue persists.
Looking for the code at Input.jsx i edit:

handleChange(e){

    const { value, composing } = e.target;
    if (composing || this.stateValue === value) return;

    clearTimeout(this.changeTimeout);

    this.changeTimeout = setTimeout(() => {

        this.setValue(value, e);

    }, !value ? 0 : 150);
}

And works as expected (i made the test with 50 inputs with validation etc)! With that debounce delay the re-render calls is drastic reduced to my case, please consider a debounce option to handle this =D thank you!

All 3 comments

@tangjinzhou thanks for your reply! Tried your example with 'self Update' but apparently the issue persists.
Looking for the code at Input.jsx i edit:

handleChange(e){

    const { value, composing } = e.target;
    if (composing || this.stateValue === value) return;

    clearTimeout(this.changeTimeout);

    this.changeTimeout = setTimeout(() => {

        this.setValue(value, e);

    }, !value ? 0 : 150);
}

And works as expected (i made the test with 50 inputs with validation etc)! With that debounce delay the re-render calls is drastic reduced to my case, please consider a debounce option to handle this =D thank you!

v-modal have same problem.
so i make a directive to hook a-input & a-textarea, it work for me...
https://gist.github.com/Muscipular/8732a5619f4bf09d5000579922f29071

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jave-joe picture jave-joe  ·  3Comments

AndesLai picture AndesLai  ·  4Comments

YingZzz picture YingZzz  ·  4Comments

kdashsoul picture kdashsoul  ·  5Comments

miyukoarc picture miyukoarc  ·  3Comments