Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions apps/obsidian/src/components/DiscourseContextView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
Notice,
FrontMatterCache,
setIcon,
setTooltip,
} from "obsidian";
import { createRoot, Root } from "react-dom/client";
import DiscourseGraphPlugin from "~/index";
Expand Down Expand Up @@ -157,12 +158,14 @@ const DiscourseContext = ({ activeFile }: DiscourseContextProps) => {
)}
{nodeType.name || "Unnamed Node Type"}
<button
ref={(el) => {
if (el)
setTooltip(el, `Create Base view for ${nodeType.name} nodes`);
}}
Comment on lines +161 to +164
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tooltip uses nodeType.name directly, but line 158 shows that nodeType.name can be falsy (using nodeType.name || "Unnamed Node Type"). When nodeType.name is undefined/null/empty, the tooltip will display inconsistent text like "Create Base view for undefined nodes" while the UI shows "Unnamed Node Type".

Fix:

ref={(el) => {
  if (el) {
    const name = nodeType.name || "Unnamed Node Type";
    setTooltip(el, `Create Base view for ${name} nodes`);
  }
}}
Suggested change
ref={(el) => {
if (el)
setTooltip(el, `Create Base view for ${nodeType.name} nodes`);
}}
ref={(el) => {
if (el)
const name = nodeType.name || "Unnamed Node Type";
setTooltip(el, `Create Base view for ${name} nodes`);
}}

Spotted by Graphite

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

onClick={() => {
void createBaseForNodeType(plugin, nodeType);
}}
className="clickable-icon ml-1"
title={`Create Base view for ${nodeType.name}`}
aria-label={`Create Base view for ${nodeType.name}`}
>
<div
ref={(el) => (el && setIcon(el, "layout-list")) || undefined}
Expand Down
Loading