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

🉐 fix: incorrect handling for composing CJK texts in Safari #5496

Merged

Conversation

oonishi3
Copy link
Contributor

@oonishi3 oonishi3 commented Jan 27, 2025

Summary

Fixed an issue where line breaks were not correctly applied in Mac/Safari environments for languages that require pressing the Enter key to confirm text input (e.g., Japanese, Chinese, etc.).

This issue was largely resolved for most environments in #3103, but the problem persisted in Mac/Safari due to differences in the behavior of isComposing.

In addition to using isComposing for composition detection, there are also KeyboardEvent.key and KeyboardEvent.keyCode. However, in Mac/Safari, it was impossible to make correct judgments using either isComposing or KeyboardEvent.key, so I reluctantly used keyCode for detection, despite it being deprecated.

To prevent issues when keyCode is removed in the future, I have implemented the keyCode-based detection after attempting detection using isComposing and key.

This PR appears to be related to #3412.

Change Type

  • Bug fix (non-breaking change which fixes an issue)

Testing

Testing can be done using a similar approach as in #3103.

When creating the pull request, I conducted tests in the following environment:

OS Browser note
macOS 15.2 Safari 18.2 (20620.1.16.11.8)
macOS 15.2 Chrome 131.0.6778.267
Windows 11 (23H2) Chrome 132.0.6834.111
Windows 11 (23H2) Firefox 134.0.2
Android 15 Chrome 132.0.6834.122
iPadOS 16.5 Safari Due to the limitations of the device I own, I'm using a slightly older version.

Checklist

Please delete any irrelevant options.

  • My code adheres to this project's style guidelines
  • I have performed a self-review of my own code
  • I have commented in any complex areas of my code
  • My changes do not introduce new warnings
    • ⚠️ While no warnings appear during testing or building, many IDEs display strikethrough lines on the relevant parts due to the use of deprecated properties.

@danny-avila danny-avila changed the title fix: incorrect handling for composing CJK texts in Safari 🉐 fix: incorrect handling for composing CJK texts in Safari Jan 27, 2025
@danny-avila danny-avila merged commit 47b72e8 into danny-avila:main Jan 27, 2025
2 checks passed
@oonishi3 oonishi3 deleted the fix/wrong-line-breaks-on-safari branch January 28, 2025 06:38
justinmdickey pushed a commit to e-gineering/LibreChat that referenced this pull request Jan 30, 2025
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.

2 participants