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
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions client/src/hooks/Input/useTextarea.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,9 @@ export default function useTextarea({
const isNonShiftEnter = e.key === 'Enter' && !e.shiftKey;
const isCtrlEnter = e.key === 'Enter' && (e.ctrlKey || e.metaKey);

// NOTE: isComposing and e.key behave differently in Safari compared to other browsers, forcing us to use e.keyCode instead
const isComposingInput = isComposing.current || e.key === 'Process' || e.keyCode === 229;

if (isNonShiftEnter && filesLoading) {
e.preventDefault();
}
Expand All @@ -204,15 +207,15 @@ export default function useTextarea({
!enterToSend &&
!isCtrlEnter &&
textAreaRef.current &&
!isComposing.current
!isComposingInput
) {
e.preventDefault();
insertTextAtCursor(textAreaRef.current, '\n');
forceResize(textAreaRef.current);
return;
}

if ((isNonShiftEnter || isCtrlEnter) && !isComposing.current) {
if ((isNonShiftEnter || isCtrlEnter) && !isComposingInput) {
const globalAudio = document.getElementById(globalAudioId) as HTMLAudioElement | undefined;
if (globalAudio) {
console.log('Unmuting global audio');
Expand Down
Loading