Skip to content
Open
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ const ExportAsTemplateDialog = ({ show, dialogProps, onCancel }) => {
}

const handleUsecaseInputKeyDown = (event) => {
if (event.key === 'Enter' && usecaseInput.trim()) {
// Check if IME composition is in progress
const isIMEComposition = event.isComposing || event.keyCode === 229
if (event.key === 'Enter' && !isIMEComposition && usecaseInput.trim()) {
event.preventDefault()
if (!usecases.includes(usecaseInput)) {
setUsecases([...usecases, usecaseInput])
Expand Down
4 changes: 3 additions & 1 deletion packages/ui/src/ui-component/dialog/SaveChatflowDialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ const SaveChatflowDialog = ({ show, dialogProps, onCancel, onConfirm }) => {
value={chatflowName}
onChange={(e) => setChatflowName(e.target.value)}
onKeyDown={(e) => {
if (isReadyToSave && e.key === 'Enter') onConfirm(e.target.value)
// Check if IME composition is in progress
const isIMEComposition = e.isComposing || e.keyCode === 229
if (isReadyToSave && e.key === 'Enter' && !isIMEComposition) onConfirm(e.target.value)
}}
/>
</DialogContent>
Expand Down
4 changes: 3 additions & 1 deletion packages/ui/src/ui-component/dialog/TagDialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ const TagDialog = ({ isOpen, dialogProps, onClose, onSubmit }) => {
}

const handleInputKeyDown = (event) => {
if (event.key === 'Enter' && inputValue.trim()) {
// Check if IME composition is in progress
const isIMEComposition = event.isComposing || event.keyCode === 229
if (event.key === 'Enter' && !isIMEComposition && inputValue.trim()) {
event.preventDefault()
if (!categoryValues.includes(inputValue)) {
setCategoryValues([...categoryValues, inputValue])
Expand Down
4 changes: 3 additions & 1 deletion packages/ui/src/views/canvas/CanvasHeader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,9 @@ const CanvasHeader = ({ chatflow, isAgentCanvas, isAgentflowV2, handleSaveFlow,
}}
defaultValue={flowName}
onKeyDown={(e) => {
if (e.key === 'Enter') {
// Check if IME composition is in progress
const isIMEComposition = e.isComposing || e.keyCode === 229
if (e.key === 'Enter' && !isIMEComposition) {
submitFlowName()
} else if (e.key === 'Escape') {
setEditingFlowName(false)
Comment on lines +487 to 490

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

When typing with an IME, pressing the Escape key is often used to cancel or close the IME candidate list or composition window. If we do not guard the Escape key handler with !isIMEComposition, pressing Escape to cancel composition will bubble up and immediately close the editing mode, discarding the user's input.

We should apply the same !isIMEComposition guard to the Escape key check.

Suggested change
if (e.key === 'Enter' && !isIMEComposition) {
submitFlowName()
} else if (e.key === 'Escape') {
setEditingFlowName(false)
if (e.key === 'Enter' && !isIMEComposition) {
submitFlowName()
} else if (e.key === 'Escape' && !isIMEComposition) {
setEditingFlowName(false)

Expand Down