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

ignore Enter on inputing with IME #6993

Merged
merged 4 commits into from
Jul 19, 2023

Conversation

chakku000
Copy link
Contributor

@chakku000 chakku000 commented Jul 12, 2023

Describe your changes

When the user types Japanese or Chinese with IME, we use "Enter" not only to send but also to confirm the character conversion.
If the application captures the "composing Enter" event as send text, it's awkward, because it results in sending even though we're still inputing the words.
This seems to be a common problem. See the follow issue on React.
#6992

For example, when I want to input the sentence in Japanese "私(watashi)は(ha)人(hito)です(desu)" , I press the following keys.
"watashi<convert_key>hahito<convert_key>desu"
As a result, the first is captured, and just "私(watashi)" is sent as a message.

To solve this problem, I found the isComposing field in nativeEvent, and I found that ignoring the isComposing event gave me comfortable input.
https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/isComposing

GitHub Issue Link (if applicable)

Testing Plan

  • Explanation of why no additional tests are needed
  • Unit Tests (JS and/or Python)
  • E2E Tests
  • Any manual testing needed?

Contribution License Agreement

By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.

Copy link
Collaborator

@vdonato vdonato left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution @chakku000!

This LGTM, but I'll also wait for @lukasmasuch to take a look as the resident expert on the st.chat_input widget. I don't think there are any unwanted side effects that this change can cause, but just being safe.

@lukasmasuch
Copy link
Collaborator

LGTM as well 👍 It feels like there could be some corner cases that this change might break, but I couldn't find anything. But we should monitor this after release if anyone complains about the Enter behaviour.

@lukasmasuch lukasmasuch merged commit 56c1f3e into streamlit:develop Jul 19, 2023
@chakku000
Copy link
Contributor Author

Thank you for your reviews

eric-skydio pushed a commit to eric-skydio/streamlit that referenced this pull request Dec 20, 2023
…6993)

* ignore Enter on composition for Japanese

* fix incorrect indent num

* write comment why uncapture Enter with isComposing

* case of the lack of no nativeEvent or isComposing

for test sets widget value when ⌘+enter
zyxue pushed a commit to zyxue/streamlit that referenced this pull request Mar 22, 2024
…6993)

* ignore Enter on composition for Japanese

* fix incorrect indent num

* write comment why uncapture Enter with isComposing

* case of the lack of no nativeEvent or isComposing

for test sets widget value when ⌘+enter
zyxue pushed a commit to zyxue/streamlit that referenced this pull request Apr 16, 2024
…6993)

* ignore Enter on composition for Japanese

* fix incorrect indent num

* write comment why uncapture Enter with isComposing

* case of the lack of no nativeEvent or isComposing

for test sets widget value when ⌘+enter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants