-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Fix #6929: relation map ignores selected autocomplete name #9104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
eliandoran
merged 5 commits into
TriliumNext:main
from
Renatonet0:fix/partially-typed-relation
May 23, 2026
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ca30530
Fix #6929: relation map ignores selected autocomplete name
1ca3a54
Fix #6929: Resolve merge conflict
cd695bc
Merge branch 'main' into fix/partially-typed-relation
Renatonet0 a1a8959
Merge branch 'main' into fix/partially-typed-relation
Renatonet0 9998b25
Merge branch 'main' into fix/partially-typed-relation
Renatonet0 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
apps/client/src/widgets/type_widgets/relation_map/RelationMap.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| import $ from "jquery"; | ||
| import { describe, expect, it, vi } from "vitest"; | ||
|
|
||
| import { setupAnswerEventHandlers } from "./RelationMap.js"; | ||
|
|
||
| vi.mock("../../../services/utils.js", async (importOriginal) => { | ||
| const actual = await importOriginal<typeof import("../../../services/utils.js")>(); | ||
| return { | ||
| ...actual, | ||
| default: { | ||
| ...actual.default, | ||
| filterAttributeName: vi.fn((val: string) => val) | ||
| } | ||
| }; | ||
| }); | ||
|
|
||
| describe("RelationMap - $answer event synchronization", () => { | ||
|
|
||
| it("dispatches input event with bubbles:true when Enter is pressed", () => { | ||
| const $answer = $("<input type='text' />"); | ||
| const dispatchSpy = vi.spyOn($answer[0], "dispatchEvent"); | ||
|
|
||
| setupAnswerEventHandlers($answer); | ||
| $answer.trigger($.Event("keydown", { key: "Enter" })); | ||
|
|
||
| expect(dispatchSpy).toHaveBeenCalledWith( | ||
| expect.objectContaining({ type: "input", bubbles: true }) | ||
| ); | ||
| }); | ||
|
|
||
| it("dispatches input event with bubbles:true when input loses focus (blur)", () => { | ||
| const $answer = $("<input type='text' />"); | ||
| const dispatchSpy = vi.spyOn($answer[0], "dispatchEvent"); | ||
|
|
||
| setupAnswerEventHandlers($answer); | ||
| $answer.trigger("blur"); | ||
|
|
||
| expect(dispatchSpy).toHaveBeenCalledWith( | ||
| expect.objectContaining({ type: "input", bubbles: true }) | ||
| ); | ||
| }); | ||
|
|
||
| it("does not dispatch input event for non-Enter keys", () => { | ||
| const $answer = $("<input type='text' />"); | ||
| const dispatchSpy = vi.spyOn($answer[0], "dispatchEvent"); | ||
|
|
||
| setupAnswerEventHandlers($answer); | ||
| $answer.trigger($.Event("keydown", { key: "a" })); | ||
| $answer.trigger($.Event("keydown", { key: "Tab" })); | ||
| $answer.trigger($.Event("keydown", { key: "Escape" })); | ||
|
|
||
| const inputEvents = dispatchSpy.mock.calls | ||
| .map(([e]) => e as Event) | ||
| .filter((e) => e.type === "input" && e.bubbles === true); | ||
| expect(inputEvents).toHaveLength(0); | ||
| }); | ||
|
|
||
| it("input event bubbles up to parent element", () => { | ||
| const $answer = $("<input type='text' />"); | ||
| const parent = document.createElement("div"); | ||
| parent.appendChild($answer[0]); | ||
|
|
||
| const parentListener = vi.fn(); | ||
| parent.addEventListener("input", parentListener); | ||
|
|
||
| setupAnswerEventHandlers($answer); | ||
| $answer.trigger($.Event("keydown", { key: "Enter" })); | ||
|
|
||
| expect(parentListener).toHaveBeenCalledOnce(); | ||
| expect(parentListener.mock.calls[0][0]).toMatchObject({ type: "input", bubbles: true }); | ||
| }); | ||
|
|
||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The separate
keydownandblurevent handlers can be combined into a single, more concise handler by leveraging jQuery's ability to listen for multiple events at once. This makes the code more compact and idiomatic.