Ink-text-input: handleSubmit

Created on 7 Mar 2019  ·  11Comments  ·  Source: vadimdemedes/ink-text-input

The quickstart on readme.md mentioned this.handleSubmit = this.handleSubmit.bind(this);, which is empty and will set off error.

Moreover, onChange is handled properly while onSubmit is not.

Maybe we need to handle ENTER?

if(s === ENTER && this.props.onSubmit && value !== originalValue){
  return this.props.onSubmit(value);
}

Most helpful comment

3rded - for now I've copied the code into a file locally and added my own onSubmit method

All 11 comments

I was just about to open an issue for this. Would be awesome! (And I see the deprecated password input component has onSubmit)

3rded - for now I've copied the code into a file locally and added my own onSubmit method

4thed - I added my own custom onSubmit too.

@danrspencer @jcar787 let's do a pull request, what do you say? :D

@entrptaher I think you should do it since you discovered the issue first and added the gist. 😊
Thanks for the gist though.

You are right.
However, I dug deep into it and found I had problem with cursorOffset when I submit using ENTER.
Then I asked on this issue :D

Hook version. You don't get the value from it though.

I guess I accidentally removed it when migrating to Ink 2 or earlier 🤷‍♂️ If anyone's willing to help out with this, would be great! If not, I will take care of it bit later this week.

19 is merged, this can be closed 🎉

@SimenB let me test the cursorOffset, I am really curious about it. :D

This works flawlessly.
The issue can be closed.

Result:

Git repo

Many thanks everyone.
Gonna go find next bug :D

Was this page helpful?
0 / 5 - 0 ratings

Related issues

colinking picture colinking  ·  3Comments

mwawrusch picture mwawrusch  ·  3Comments

danieljack picture danieljack  ·  3Comments

exortech picture exortech  ·  3Comments

iklementiev picture iklementiev  ·  3Comments