-
Notifications
You must be signed in to change notification settings - Fork 6
Fix: Remove leading # from search result tags in advanced search #1115
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -49,8 +49,10 @@ import { AdvancedSearchFooter } from "./AdvancedSearchFooter"; | |
|
|
||
| type Props = Record<string, unknown>; | ||
|
|
||
| const getNodeBadgeText = (node: DiscourseNode): string => | ||
| (node.tag?.trim() || node.text).slice(0, 3).toUpperCase(); | ||
| const getNodeBadgeText = (node: DiscourseNode): string => { | ||
| const text = (node.tag?.trim() || node.text).replace(/^#/, ""); | ||
| return text.slice(0, 3).toUpperCase(); | ||
| }; | ||
|
|
||
| const getTagStyle = (node: DiscourseNode | undefined): React.CSSProperties => { | ||
| const color = node?.canvasSettings?.color; | ||
|
|
@@ -102,7 +104,9 @@ const ResultRow = ({ | |
| }} | ||
| > | ||
| <Tag minimal style={getTagStyle(nodeConfig)}> | ||
| {nodeConfig ? getNodeBadgeText(nodeConfig) : result.nodeTypeLabel} | ||
| {nodeConfig | ||
| ? getNodeBadgeText(nodeConfig) | ||
| : result.nodeTypeLabel.replace(/^#/, "").slice(0, 3).toUpperCase()} | ||
|
Comment on lines
+107
to
+109
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚩 Fallback branch now truncates nodeTypeLabel (behavioral change) Previously when Was this helpful? React with 👍 or 👎 to provide feedback. |
||
| </Tag> | ||
| <span className="min-w-0 break-words text-sm leading-snug text-gray-900"> | ||
| {renderHighlightedText(stripTypePrefix(result.title), keywords)} | ||
|
|
||
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.
🟡 Duplicated badge-formatting logic inline instead of reusing a utility function
The badge text formatting logic
.replace(/^#/, "").slice(0, 3).toUpperCase()at line 109 duplicates the same transformation already implemented ingetNodeBadgeText(lines 52-55). This violates the AGENTS.md rule: "Prefer util functions for reusable logic and common operations" and "Prefer small, focused functions over inline code". A small helper (e.g.,formatBadgeText(label: string): string) should be extracted and used in bothgetNodeBadgeTextand the fallback branch.Prompt for agents
Was this helpful? React with 👍 or 👎 to provide feedback.