obsidian-dataview icon indicating copy to clipboard operation
obsidian-dataview copied to clipboard

Embedded notes miss link to note

Open Gnopps opened this issue 1 year ago • 2 comments

What happened?

Using Dataview v0.5.64 or below and embedding a note using dataviewjs, using dv.el("p", "![[" + file.name + "]]") there is a button to click to take you to the embedded note. The same behaviour is there if you embed a note not using Dataview, i.e. just linking in the note using ![[note]]. Example below of an embedded note (using the JS-code provided below) and the link-button.

image

Starting with Dataview v0.5.65, this button to open the embedded note is gone. The button is still there when embedding notes manually but not when using dataviewjs. I suspect this bug has come about with the embed-rendering fixes that @GottZ did in #2266, #2261, or #2265 ?

So bug is that the "Open link"-icon is missing and needs to be restored.

DQL

No response

JS

let meetings = dv.pages(`"${dv.current().file.folder}" and #meeting`)
meetings = meetings.sort(k => k.date.path.split("/").last(), 'desc')
for (let meeting of meetings){
dv.el("p", "![[" + meeting.file.name + "]]");
}

Dataview Version

0.5.66

Obsidian Version

1.5.12

OS

Windows

Gnopps avatar Apr 11 '24 13:04 Gnopps

good catch. the change I did involved replacing a deprecated API with the "to be used" one (as suggested by obsidian.md docs itself) I'll dig a little. you are right, this should be fixed.

image

issue is easily reproducible.

image

````dataviewjs
const file = dv.current().file;
const {path, folder, name, link, ext} = file;
dv.span("```json\n"+ JSON.stringify({path, folder, name, link, ext}, null, "  ") +"\n```")
````
![[test nested]]
```dataviewjs
dv.span("![[test nested]]")
```

this and this this is the essence of the fix, so I suspect undefined behavior in obsidian itself.

Update: I've now embedded this note inside another note and noticed the same behavior. apparently when embedding notes with dvjs, the link will not even be added recursively.

GottZ avatar Apr 11 '24 17:04 GottZ

@GottZ do you know if this has been reported to Obsidian? If not I'm happy to do it, though I don't really know what to reference when reporting.

Gnopps avatar Jun 05 '24 10:06 Gnopps