Data-path is not updated in the file explorer

Steps to reproduce

  1. Create a new directory named anything, but Untitled
  2. Create another directory
  3. Move the first directory into the second

Expected result

data-path attribute should be updated on rename or move to reflect the correct path of the directory.

Actual result

data-path remains Untitled after both operations (rename, move).

The application needs to be restarted in order to reflect the correct path.

Environment

  • Operating system: macOS Big Sur (11.3.1)
  • Obsidian version: v0.12.3

I am not sure what your talking about.
Post a screen recording.

Here is a screenshot with the developer console open:

I highlighted the relevant tags containing data-path with the value Untitled. If I restart the application, those attributes would be test and test/test2 respectively.

Hope that clarifies the problem.

ok, does this create usability problems?

Have you tried querying the .dataset via the console? The dev tools don’t always reflect these kind of changes.

I added icons to my folders from CSS, like this:

.nav-folder-title[data-path="projects"] .nav-folder-title-content::before,
.nav-folder-title[data-path="archive/projects"] .nav-folder-title-content::before {
  content: "📋 ";
  font-size:1.3em;
}

When I create a new directory, the style doesn’t get applied (but it’s not a CSS loading issue, because changing existing styles work). Restarting the app fixes the problem.

Querying yields the same result.

Maybe I’m confused here, but I don’t see this as an Obsidian bug, @sagikazarmark and @WhiteNoise. The data-path attribute is meaningless by itself. It’s only meant to exchange information between HTML and its DOM representation via scripts. data-path is not a PATH to anything.

The reason it won’t update on the fly in developer tools is because it’s only read when the page is loaded. Nor is the data-* attribute used to style anything. The only relevance it has is the information within it used by the DOM. In this case, the values passed in are folder names, or directory’s if you prefer. They’re read as #text in the DOM and have no styling attached whatsoever.

The reason this doesn’t work properly:

.nav-folder-title[data-path="projects"] .nav-folder-title-content::before,
.nav-folder-title[data-path="archive/projects"] .nav-folder-title-content::before {
    content: "📋 ";
    font-size:1.3em;
}

is because Obsidian is looking for classes named: .nav-folder-title[data-path="projects"] and .nav-folder-title[data-path="archive/projects"]. There are none. I think what you’re looking for is:

.nav-folder-children .nav-folder-title-content::before {
    content: '📁'/*\1F5BF*/;
    font-size: .9em;
}
.nav-folder-children .nav-file-title-content::before {
    content: "📄"/*\1F5D0*/;
    font-size: .85em;
} /* Example from @SlRvb stunning ITS Theme – Adapt accordingly */

It’s not necessary to style one folder at a time, after they’re created. The above will style each new folder or file automatically.

That said, if you want to see those custom data-* values, Command/Control + R is only two keyboard clicks away.

I hope this helps. Here’s some other resources to peruse at your leisure.

I do think @sagikazarmark wants to style per file.

I don’t consider this major “bug”. This is more a feature request/developer request.

Actually, I am gonna close this. Please, open a FR to keep the data-path updated.

I agree that this is not a major bug, but I do think it’s a bug. The value Untitled is certainly not valid. But I’ll open a feature request if you prefer.