dmitrizzle / chat-bubble

Simple chatbot UI for the Web with JSON scripting 👋🤖🤙
MIT License
579 stars 171 forks source link

Toggle Text Input #58

Closed JensThanx closed 6 years ago

JensThanx commented 6 years ago

It would be great if the text input could simply toggled on/off. Depending on the dialog it might sometimes make sense to only allow limited choices and sometimes to allow text input. Or is it already possible, e.g. by passing in a "inputCallbackFn" to my "Bubbles" object or by setting it to "null"?

dmitrizzle commented 6 years ago

I've never tried doing that, but perhaps inputCallbackFn can do just that!

JensThanx commented 6 years ago

If I call the "typeInput" function the text input field indeed appears. But passing (null) e.g. only creates another text input field on top. So it is somewhat safe to do so. Probably "typeInput" should not even be exposed to the outside.

dmitrizzle commented 6 years ago

I think a better way may be initializing inputCallbackFn as in the example 3-keyboard-input.html and use inputCallbackFn to either show or hide it with CSS. Because typeInput function is used to initialize the input component, which also requires an input processor function - meaning that it should ever be called only once to set things up; once it's there it should just work.

If you are to do this with CSS, there should be no issues as duplicating keyboard input or non-functioning keyboard input.

JensThanx commented 6 years ago

True. It is rather a matter of visibility.

dmitrizzle commented 6 years ago

Cool! I'll mark it solved, we can re-open this ticket if necessary in the future 👍