Skip to content

Build your personal knowledge base with Trilium Notes

test(client): relation map IME composition incorrect

Elian Doranec9b15a9735c
diff --git a/apps/client/src/widgets/type_widgets/relation_map/RelationMap.spec.ts b/apps/client/src/widgets/type_widgets/relation_map/RelationMap.spec.ts
index eb48527f21..ad1cc9813e 100644
--- a/apps/client/src/widgets/type_widgets/relation_map/RelationMap.spec.ts
+++ b/apps/client/src/widgets/type_widgets/relation_map/RelationMap.spec.ts
@@ -1,5 +1,6 @@
-import { describe, it, expect, vi, beforeEach } from "vitest";
import $ from "jquery";
+import { beforeEach,describe, expect, it, vi } from "vitest";
+
import dialog from "../../../services/dialog";
vi.mock("../../../services/utils", async (importOriginal) => {
@@ -8,7 +9,7 @@ vi.mock("../../../services/utils", async (importOriginal) => {
...actual,
default: {
...actual.default,
- filterAttributeName: vi.fn((val: string) => val.replace(/[^a-z0-9]/gi, ""))
+ filterAttributeName: vi.fn((val: string) => val.replace(/[^\p{L}\p{N}_:]/gu, ""))
}
};
});
@@ -74,7 +75,7 @@ describe("IME composition handling - Chinese input (promptForRelationName)", ()
expect(input.value).toBe("ning");
});
- it("filters invalid characters from input after IME composition ends", () => {
+ it("preserves valid Unicode characters after IME composition ends", () => {
input.dispatchEvent(new Event("compositionstart"));
// intermediate pinyin
@@ -87,7 +88,7 @@ describe("IME composition handling - Chinese input (promptForRelationName)", ()
input.value = "你";
input.dispatchEvent(new Event("compositionend"));
- expect(input.value).toBe("");
+ expect(input.value).toBe("你");
});
it("allows normal latin input after Chinese composition ends", () => {
@@ -114,6 +115,6 @@ describe("IME composition handling - Chinese input (promptForRelationName)", ()
input.value = "好";
input.dispatchEvent(new Event("compositionend"));
- expect(input.value).toBe("");
+ expect(input.value).toBe("好");
});
});
diff --git a/apps/client/src/widgets/type_widgets/relation_map/RelationMap.tsx b/apps/client/src/widgets/type_widgets/relation_map/RelationMap.tsx
index ad9d69c25e..8a32ffd831 100644
--- a/apps/client/src/widgets/type_widgets/relation_map/RelationMap.tsx
+++ b/apps/client/src/widgets/type_widgets/relation_map/RelationMap.tsx
@@ -402,18 +402,6 @@ function useNoteDragging({ containerRef, mapApiRef }: {
return dragProps;
}
-export function setupAnswerEventHandlers($answer: JQuery<HTMLElement>) {
- $answer.on("keydown", (e) => {
- if (e.key === "Enter") {
- $answer[0].dispatchEvent(new Event("input", { bubbles: true }));
- }
- });
-
- $answer.on("blur", () => {
- $answer[0].dispatchEvent(new Event("input", { bubbles: true }));
- });
-}
-
function useRelationCreation({ mapApiRef, jsPlumbApiRef }: { mapApiRef: RefObject<RelationMapApi>, jsPlumbApiRef: RefObject<jsPlumbInstance> }) {
const connectionCallback = useCallback(async (info: OnConnectionBindInfo, originalEvent: Event) => {
const connection = info.connection;
@@ -445,4 +433,3 @@ function useRelationCreation({ mapApiRef, jsPlumbApiRef }: { mapApiRef: RefObjec
return connectionCallback;
}
-