Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
dentro-innovation opened this issue Mar 19, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@dentro-innovation
Copy link
Contributor

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:

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.

@picklelo picklelo added the bug Something isn't working label Mar 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants