SkepticMystic / breadcrumbs

Add typed-links to your Obsidian notes
https://publish.obsidian.md/breadcrumbs-docs
MIT License
514 stars 36 forks source link

Bug: Latest update breaks tag-notes #239

Closed chrisgrieser closed 2 years ago

chrisgrieser commented 2 years ago

since the latest update (v.2.20), tag-notes have stopped working completely. Link-Notes, Folder-notes and everything else still shows up, but tag-notes do not show up anymore.

SkepticMystic commented 2 years ago

@chrisgrieser can you share the configuration of your tag note. Something like

---
BC-tag-note: ' #tag'
BC-tag-note-field: down
---
SkepticMystic commented 2 years ago

I've changed the behaviour of tag notes. This is the new logic:

  1. Check for a BC-tag-note-field
  2. If there isn't one for that tag note, use the chosen default tag note field from settings
  3. If the user has chosen <blank> as their default, use the first field of all the fields image
chrisgrieser commented 2 years ago

here is a screenshot. I have a total of 28 notes with the tag #wissenschaftssoziologie, only one of them shows up in breadcrumbs.

Screenshot 2022-01-06 11 58 03
chrisgrieser commented 2 years ago

looking at the note, I think I found the issue. It's the only note that has #tag in its body, the others have tags in the yaml header.

I tested it adding a tag to the yaml header and then breadcrumbs indeed picks it up. So it's an issue of breadcrumbs not recognizing tags in the yaml anymore

SkepticMystic commented 2 years ago

Ahhh interesting, ok. I'll have to check what's going wrong there

elkadre commented 2 years ago

Similar issue but it's not picking up on tags in general, regardless of where they are.

Screen Shot 2022-01-06 at 17 58 21
dylan-wu commented 2 years ago

Reproduced the bug with a simple case.

Create folder and add an empty note.

Here's a GIF:

tag-notes-bug

SkepticMystic commented 2 years ago

Thank you everyone for the feedback. I'm trying to resolve this issue, but also struggling to reproduce it... Can you try out the latest release and see if tag notes work again

chrisgrieser commented 2 years ago

nope, still the same here, only inline-text tags working for me

SkepticMystic commented 2 years ago

@chrisgrieser how about now in the latest release?

SkepticMystic commented 2 years ago

Wait, I see the error now. Give me a sec

SkepticMystic commented 2 years ago

@chrisgrieser the issue is that Obsidian doesn't recognise tags: b, d as actual tags. So I have to treat those differently. Not an issue, but that's why it wasn't detecting them after the change

SkepticMystic commented 2 years ago

Ok, for realsies. This issue should be fixed now

chrisgrieser commented 2 years ago

yep, works now :)

(Thanks for the fix! I'll leave it open as @lkadre reported an issue which could be different)

elkadre commented 2 years ago

Unfortunately it's still not working for me. I'm attaching the Console log, it seems to have some BC errors related to .addTagNotesTo Graph and .getAllTags.

obsidian.md-1641765622815.log

SkepticMystic commented 2 years ago

@lkadre do you have any idea which notes are causing the errors? From your console logs (thanks!) I suspect the issue is a rogue tag, or a syntax Breadcrumbs isn't expecting. If you can send some examples of how you store your tags (in frontmatter), that'd be really helpful :)

elkadre commented 2 years ago

Pretty much all of the tag notes seem to not be working. All the other hierarchies are fine (hierarchy note, inline and frontmatter fields).

I actually store the tags in the body of the note (lists/pseudoadmonitions). I've made some tests moving them around; no luck so far, but perhaps the issue is that they're wrapped in a different CSS class?

I do have one or two tags that I store in the frontmatter as seen below. They're not used by Breadcrumbs in any hierarchies. Another possibility I can think of is that they're subtags.

Here are some example of Tag Notes:

---
creationdate: Wednesday 22nd September 2021
creationdatetime: 17:41
zettelkasten: 202109221741
cssclass: admonitions
BC-tag-note: '#law/contract'
aliases: 
tags:
  - 060-concepts
---

- [i] #law/contract 
---
creationdate: Saturday 27th November 2021
creationdatetime: 04:04
zettelkasten: 202111270404
BC-tag-note: '#m/postmodernism'
cssclass: admonitions
aliases: 
tags:
  - 060-concepts
---

- [i] #m/postmodernism 

And notes that I would expect to show as a "child", which show up on tag search but not on the matrix/list:

---
creationdate: Friday 3rd September 2021
creationdatetime: 18:01
zettelkasten: 202109031801
cssclass: admonitions
aliases: [United Nations Convention on Contracts for the International Sale of Goods, Vienna Convention]
tags:
  - 060-concepts
---

- [i] #t/treaty #law/contract 
---
creationdate: Saturday 27th November 2021
creationdatetime: 04:01
zettelkasten: 202111270401
cssclass: admonitions
aliases:
tags:
  - 040-people
---

- [i] fullname:: Paul-Michel Foucault
- [i] birthyear:: 1926
- [i] deathyear:: 1984
- [i] nationality:: #civ/FR 
- [I] #m/postmodernism 
SkepticMystic commented 2 years ago

@lkadre can you please post this in the console, and hit enter while focussed on a note with lots of tags in it. Check to see that all the tags are in the result, and that they all start with #.

let getAllTags = (file, withHash = true) => {
    const { tags, frontmatter } = app.metadataCache.getFileCache(file);
    const allTags = [];

    tags?.forEach((t) => allTags.push(dropHash(t.tag)));

    [frontmatter?.tags ?? []].flat().forEach((t) => {
      splitAndTrim(t).forEach((innerT) => allTags.push(dropHash(innerT)));
    });
    [frontmatter?.tag ?? []].flat().forEach((t) => {
      splitAndTrim(t).forEach((innerT) => allTags.push(dropHash(innerT)));
    });

    return allTags.map((t) => (withHash ? "#" : "") + t.toLowerCase());
  };

let dropHash = (tag) =>
  tag.startsWith("#") ? tag.slice(1) : tag;

let splitAndTrim = (fields) => {
  if (fields === "") return [];
  else return fields.split(",").map((str) => str.trim());
};

getAllTags(app.workspace.getActiveFile())
elkadre commented 2 years ago

Tested on the first "child note" above. It does show all tags, but then has an error.

obsidian.md-1641835047252.log

Screen Shot 2022-01-10 at 14 15 29
SkepticMystic commented 2 years ago

@lkadre I don't think that error comes from Breadcrumbs... I don't recognise any of the things in it. But that's even weirder, it finds all the tags correctly, and there aren't any errors. I'll have to keep testing

SkepticMystic commented 2 years ago

@lkadre I'm trying every test case I can possibly think of, and they all work...

elkadre commented 2 years ago

I turned off every other plugin (including Dataview) and reset to the default theme to see what happened. Still the same error...

Obsidian Developer Console
VM109:52737 loading breadcrumbs plugin
2VM109:53847 TypeError: Cannot read property 'split' of null
    at splitAndTrim (eval at <anonymous> (app.js:1), <anonymous>:22481:23)
    at eval (eval at <anonymous> (app.js:1), <anonymous>:52673:17)
    at Array.forEach (<anonymous>)
    at BCPlugin.getAllTags (eval at <anonymous> (app.js:1), <anonymous>:52672:140)
    at hasThisTag (eval at <anonymous> (app.js:1), <anonymous>:53521:38)
    at eval (eval at <anonymous> (app.js:1), <anonymous>:53528:69)
    at Array.filter (<anonymous>)
    at eval (eval at <anonymous> (app.js:1), <anonymous>:53528:18)
    at Array.forEach (<anonymous>)
    at BCPlugin.addTagNotesToGraph (eval at <anonymous> (app.js:1), <anonymous>:53514:22)
initGraphs @ VM109:53847
SkepticMystic commented 2 years ago

@lkadre Ahhh sorry! I see now you posted the log file. The error in the screenshot isn't BC-related, but this one definitely is. Ok, I've added a patch in the latest release. I don't know why thee error you posted happens, but the patch should bypass it

elkadre commented 2 years ago

IT WORKS NOW!!! that was some detective work, thank you so much for your patience!

SkepticMystic commented 2 years ago

Ahh that's great to hear 😄 Phew, that was a sneaky bug, indeed. The underlying issue is not actually resolved. I believe the cause it that one of your notes has a blank tags field tag: or tags:. That would probably cause the problem you faced here. But the patch does overcome that, so all is well

SkepticMystic commented 2 years ago

Alright, I'm gonna close this issue then 😋