Browse Source

docs: resolve ime error in search (#2651)

Co-authored-by: 田丰 <[email protected]>
田丰 9 months ago
parent
commit
3dbb4c0608
1 changed files with 11 additions and 0 deletions
  1. 11 0
      packages/semi-ui/jsonViewer/index.tsx

+ 11 - 0
packages/semi-ui/jsonViewer/index.tsx

@@ -55,6 +55,7 @@ class JsonViewerCom extends BaseComponent<JsonViewerProps, JsonViewerState> {
     private editorRef: React.RefObject<HTMLDivElement>;
     private editorRef: React.RefObject<HTMLDivElement>;
     private searchInputRef: React.RefObject<HTMLInputElement>;
     private searchInputRef: React.RefObject<HTMLInputElement>;
     private replaceInputRef: React.RefObject<HTMLInputElement>;
     private replaceInputRef: React.RefObject<HTMLInputElement>;
+    private isComposing: boolean = false;
 
 
     foundation: JsonViewerFoundation;
     foundation: JsonViewerFoundation;
 
 
@@ -190,6 +191,16 @@ class JsonViewerCom extends BaseComponent<JsonViewerProps, JsonViewerState> {
                     className={`${prefixCls}-search-bar-input`}
                     className={`${prefixCls}-search-bar-input`}
                     onChange={(_value, e) => {
                     onChange={(_value, e) => {
                         e.preventDefault();
                         e.preventDefault();
+                        if (!this.isComposing) {
+                            this.searchHandler();
+                        }
+                        this.searchInputRef.current?.focus();
+                    }}
+                    onCompositionStart={() => {
+                        this.isComposing = true;
+                    }}
+                    onCompositionEnd={() => {
+                        this.isComposing = false;
                         this.searchHandler();
                         this.searchHandler();
                         this.searchInputRef.current?.focus();
                         this.searchInputRef.current?.focus();
                     }}
                     }}