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

enter_key_submit doesn't work for rx.text_area if value is set (works for rx.el.textarea). #4080

Open
TimChild opened this issue Oct 7, 2024 · 1 comment · May be fixed by #4084
Open

enter_key_submit doesn't work for rx.text_area if value is set (works for rx.el.textarea). #4080

TimChild opened this issue Oct 7, 2024 · 1 comment · May be fixed by #4084
Labels
bug Something isn't working

Comments

@TimChild
Copy link
Contributor

TimChild commented Oct 7, 2024

Describe the bug
Trying to set enter_key_submit on the rx.text_area has no effect if value is set. It works as expected on the rx.el.textarea

To Reproduce
Steps to reproduce the behavior:

app = rx.App(state=rx.State)


class State(rx.State):
    submitted: str = ""

    area_1: str = ""
    area_2: str = ""

    def handle_submit(self, form_data: dict):
        self.submitted = str(form_data)


def layout() -> rx.Component:
    return rx.vstack(
        rx.form(
            rx.text_area(
                enter_key_submit=True,
                name="works_without_value",
                placeholder="works with no value set",
            ),
            rx.text_area(
                value=State.area_1,
                on_change=State.set_area_1,
                enter_key_submit=True,
                name="not_working",
                placeholder="doesn't work",
            ),
            rx.el.textarea(
                value=State.area_2,
                on_change=State.set_area_2,
                enter_key_submit=True,
                name="works",
                placeholder="works",
            ),
            on_submit=State.handle_submit,
        ),
        rx.text(State.submitted)
    )


app.add_page(layout, route="/")

Expected behavior
Expect same behaviour in all three cases

Specifics (please complete the following information):

  • Python Version: 3.12
  • Reflex Version: 0.6.1
  • OS: WSL2
  • Browser (Optional): Chrome

Additional context
Not obvious to me why the behaviour changes when value is set only on the radix themed text_area and not the regular one.

@TimChild TimChild added the bug Something isn't working label Oct 7, 2024
@TimChild
Copy link
Contributor Author

TimChild commented Oct 7, 2024

Just had a quick look again and realised the difference is the DebounceInput that gets applied to the radix version if both value and on_change are set... So I think a fix for this is just to add an extra condition to check that enter_key_submit is not set.

I'll create a PR now, but maybe there is a better way to implement that doesn't require removing the DebounceInput since that is a nice feature to have.

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

Successfully merging a pull request may close this issue.

1 participant