mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-07-10 16:23:44 +00:00
🌏 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:
parent
61e1633b84
commit
5789f89a3f
3 changed files with 11 additions and 4 deletions
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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('');
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
}}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue