reflex-chat icon indicating copy to clipboard operation
reflex-chat copied to clipboard

Not working to submit a form with `rx.radix.text_field.input` that has `autofocus=True`

Open dentroai opened this issue 11 months ago • 0 comments

Describe the bug When using autofocus with rx.radix.text_field.input the cursor is successfully captured when opening the site, but when submitting the message there's an error:

Traceback (most recent call last):
  File "/reflex-chat/.venv/lib/python3.10/site-packages/reflex/state.py", line 1442, in _process_event
    async for event in events:
  File "/reflex-chat/webui/webui/state.py", line 91, in process_question
    async for value in model(question):
  File "/reflex-chat/webui/webui/state.py", line 102, in openai_process_question
    qa = QA(question=question, answer="")
  File "pydantic/main.py", line 341, in pydantic.main.BaseModel.__init__
pydantic.error_wrappers.ValidationError: 1 validation error for QA
question
  none is not an allowed value (type=type_error.none.not_allowed)

Somehow the question which is passed into openai_process_question is None and doesn't have any value.

To Reproduce Steps to reproduce the behavior:

  • Code/Link to Repo: https://github.com/reflex-dev/reflex-chat

Add the following line autofocus=True to text_field.input:

rx.radix.text_field.root(
                            rx.radix.text_field.input(
                                placeholder="Type something...",
                                id="question",
                                width=["15em", "20em", "30em", "30em", "30em", "30em"],
                                autofocus=True, # <- THIS CHANGED
                            ),
                            rx.radix.text_field.slot(
                                rx.tooltip(
                                    rx.icon("info", size=18),
                                    content="Enter a question to get a response.",
                                )
                            ),
                        ),

Run reflex init; reflex run inside the /webui folder, then type something in the input field and submit.

Expected behavior Cursor gets captured on the text input field while the rest of the behavior stays the same, i.e. I can still submit messages

Screenshots image

Specifics (please complete the following information):

  • Python Version: 3.10
  • Reflex Version: 0.4.4
  • OS: Debian Based
  • Browser (Optional): Firefox and Chrome

Additional context Would be lovely being able to add autofocus to the input field.

dentroai avatar Mar 19 '24 18:03 dentroai