🌏 fix: guard IME composition on Enter in prompt name/labels and dynamic tag inputs (#13996)

* 🌏 fix: guard IME composition on Enter in prompt name/labels and dynamic tag inputs

* style: sort imports in DynamicTags per repo import-order convention

---------

Co-authored-by: greymoth <246701683+greymoth-jp@users.noreply.github.com>
This commit is contained in:
greymoth 2026-07-06 00:37:52 +09:00 committed by GitHub
parent 61e1633b84
commit 5789f89a3f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 11 additions and 4 deletions

View file

@ -53,7 +53,8 @@ const PromptName: React.FC<Props> = ({ name, isLoading = false, isError = false,
setNewName(name);
setIsEditing(false);
}
if (e.key === 'Enter') {
// Ignore the Enter that commits an IME composition (see useTextarea.ts).
if (e.key === 'Enter' && !(e.nativeEvent.isComposing || e.keyCode === 229)) {
e.preventDefault();
skipBlurRef.current = true;
commitName();

View file

@ -16,7 +16,12 @@ const PromptLabelsForm = ({ selectedPrompt }: { selectedPrompt?: TPrompt }) => {
};
const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
if (e.key === 'Enter' && labelInput.trim()) {
// Ignore the Enter that commits an IME composition (see useTextarea.ts).
if (
e.key === 'Enter' &&
!(e.nativeEvent.isComposing || e.keyCode === 229) &&
labelInput.trim()
) {
const newLabels = [...labels, labelInput.trim()];
setLabels(newLabels);
setLabelInput('');

View file

@ -1,6 +1,6 @@
import { useState, useMemo, useCallback, useRef } from 'react';
import type { DynamicSettingProps } from 'librechat-data-provider';
import { Label, Input, HoverCard, HoverCardTrigger, Tag, useToastContext } from '@librechat/client';
import type { DynamicSettingProps } from 'librechat-data-provider';
import { TranslationKeys, useLocalize, useParameterEffects } from '~/hooks';
import { useChatContext } from '~/Providers';
import OptionHover from './OptionHover';
@ -155,7 +155,8 @@ function DynamicTags({
if (e.key === 'Backspace' && !tagText) {
onTagRemove(currentTags.length - 1);
}
if (e.key === 'Enter') {
// Ignore the Enter that commits an IME composition (see useTextarea.ts).
if (e.key === 'Enter' && !(e.nativeEvent.isComposing || e.keyCode === 229)) {
onTagAdd();
}
}}