RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.
Go agent-harnessagent-native-databaseagentic-aiagentic-retrievalagentic-searchaiai-agentscontext-enginecontext-engineeringcontext-managementharness-engineeringknowledge-compilationragretrieval-augmented-generationretrieval-harnesssearch-harness
fix(web): ignore IME composition Enter in tag input (#17322)
Try everythingedd3323055db
diff --git a/web/src/components/edit-tag/__tests__/index.test.tsx b/web/src/components/edit-tag/__tests__/index.test.tsxnew file mode 100644index 0000000000..b8cc2a0396--- /dev/null+++ b/web/src/components/edit-tag/__tests__/index.test.tsx@@ -0,0 +1,44 @@+import { fireEvent, render, screen } from '@testing-library/react';+import React from 'react';++// `ui/button` pulls in react-router, whose dev build touches `TextEncoder` at+// import time (absent in jsdom). We only need a passthrough `Link` here.+jest.mock('react-router', () => ({+ Link: ({ children }: { children?: unknown }) => children,+}));++import EditTag from '..';++describe('EditTag Enter handling', () => {+ const setup = () => {+ const onChange = jest.fn();+ render(+ React.createElement(EditTag, {+ value: [],+ onChange,+ addButtonTestId: 'add-tag',+ inputTestId: 'tag-input',+ }),+ );+ fireEvent.click(screen.getByTestId('add-tag'));+ const input = screen.getByTestId('tag-input');+ fireEvent.change(input, { target: { value: 'foo' } });+ return { onChange, input };+ };++ it('does not confirm the tag on the Enter that ends an IME composition', () => {+ const { onChange, input } = setup();++ fireEvent.keyDown(input, { key: 'Enter', isComposing: true });++ expect(onChange).not.toHaveBeenCalled();+ });++ it('confirms the tag on a plain Enter press', () => {+ const { onChange, input } = setup();++ fireEvent.keyDown(input, { key: 'Enter' });++ expect(onChange).toHaveBeenCalledWith(['foo']);+ });+});diff --git a/web/src/components/edit-tag/index.tsx b/web/src/components/edit-tag/index.tsxindex ec26b612f5..1779859a64 100644--- a/web/src/components/edit-tag/index.tsx+++ b/web/src/components/edit-tag/index.tsx@@ -119,7 +119,10 @@ const EditTag = React.forwardRef<HTMLDivElement, EditTagsProps>(disabled={disabled}data-testid={inputTestId}onKeyDown={(e) => {- if (e?.key === 'Enter') {+ // Ignore the Enter that confirms an IME (e.g. Chinese/Japanese)+ // composition, otherwise the half-composed text is committed as a+ // tag and the input closes before the user finishes typing.+ if (e?.key === 'Enter' && !e.nativeEvent.isComposing) {handleInputConfirm();}}}