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

feat: Add trigger_on_enter parameter to ui.inline #372 #1744

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

sherrychen2
Copy link

This PR adds a new trigger_on_enter parameter to ui.inline that allows users to press the Enter key to submit the form in textbox.tsx.

The feature is showcased in textbox.py by adding a ui.textbox that submits when pressing the Enter key:

ui.textbox(name='textbox_enter', label='Submit the form when pressing the Enter key', trigger_on_enter=True),
Screenshot.2022-12-08.at.22.16.39.mov

Unit tests were added in textbox.test.tsx as follows:

it('Doesn\'t submit when the Enter key is pressed by default', () => {
   const { getByTestId } = render(<XTextbox model={{ ...textboxProps }} />)
   userEvent.type(getByTestId(name), '123{Enter}')
   expect(pushMock).not.toBeCalled()
 })

it('Submits when the Enter key is pressed using the trigger_on_enter option', () => {
   const { getByTestId } = render(<XTextbox model={{ ...textboxProps, trigger_on_enter: true }} />)
   userEvent.type(getByTestId(name), '123{Enter}')
   expect(pushMock).toBeCalled()
 })

Closes #372.

Copy link
Collaborator

@mturoci mturoci left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @sherrychen2. We need to discuss this with @lo5 and get back to you, but the implementation will most likely need to be adhered to #348 (comment) instead of introducing a new trigger_on_enter attr.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add enter handler for textbox
3 participants