Skip to content

fix(trashbin): context menu label not updating#3744

Merged
rxri merged 2 commits intospicetify:mainfrom
yetval:fix/trashbin-context-menu-label
Mar 22, 2026
Merged

fix(trashbin): context menu label not updating#3744
rxri merged 2 commits intospicetify:mainfrom
yetval:fix/trashbin-context-menu-label

Conversation

@yetval
Copy link
Contributor

@yetval yetval commented Mar 22, 2026

`shouldAddContextMenu` used `this.name` to update the context menu label, but `this` is no longer bound to the `ContextMenu.Item` in newer Spicetify versions. Referencing `cntxMenu` directly via closure fixes the stale label.

Fixes #3743

Summary by CodeRabbit

  • Bug Fixes
    • Corrected context-menu labeling in the trashbin extension so menu items display and reference the proper label for track and artist entries.

Replace `this.name` with direct `cntxMenu` reference in shouldAddContextMenu.
`this` is no longer bound to the ContextMenu.Item in newer Spicetify versions.

Fixes spicetify#3743
@coderabbitai
Copy link

coderabbitai bot commented Mar 22, 2026

📝 Walkthrough

Walkthrough

Updated context-menu labeling in the Trashbin extension: the label assignments inside shouldAddContextMenu(uris) were changed to set cntxMenu.name (previously this.name) for TRACK and ARTIST URI cases; the context menu item instance remains created as const cntxMenu, and the function's return behavior is unchanged.

Changes

Cohort / File(s) Summary
Trashbin context menu
Extensions/trashbin.js
In shouldAddContextMenu(uris), updated context-menu label assignments to assign to cntxMenu.name instead of this.name for TRACK and ARTIST URI branches. The existing const cntxMenu = new Spicetify.ContextMenu.Item(...) remains; boolean return behavior preserved.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 I nibble at a tiny bug tonight,
I tweak the name so labels shine just right,
A hop, a fix, a quiet little cheer,
Trashbin whispers clear — no more confusion here 🥕✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed The code changes fix the stale label binding issue by referencing cntxMenu directly via closure instead of using 'this', directly addressing the requirement in issue #3743.
Out of Scope Changes check ✅ Passed All changes are scoped to the trashbin context menu label update in shouldAddContextMenu(), directly aligned with the fix objectives.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Title check ✅ Passed The title accurately describes the main fix—updating context menu label binding in the trashbin extension from stale this.name to cntxMenu.name.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

CodeRabbit can suggest fixes for GitHub Check annotations.

Configure the reviews.tools.github-checks setting to adjust the time to wait for GitHub Checks to complete.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
Extensions/trashbin.js (1)

357-358: const is sufficient here; let is unnecessary.

The variable cntxMenu is never reassigned—only its .name property is mutated. Property mutations are allowed on const objects. Using const better communicates intent that this binding won't change.

Suggested change
-	let cntxMenu = new Spicetify.ContextMenu.Item(THROW_TEXT, toggleThrow, shouldAddContextMenu, trashbinIcon);
+	const cntxMenu = new Spicetify.ContextMenu.Item(THROW_TEXT, toggleThrow, shouldAddContextMenu, trashbinIcon);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Extensions/trashbin.js` around lines 357 - 358, Change the binding for the
context menu item from a mutable variable to an immutable one: replace the `let
cntxMenu = new Spicetify.ContextMenu.Item(THROW_TEXT, toggleThrow,
shouldAddContextMenu, trashbinIcon);` declaration with a `const` so the binding
is not reassigned (the object’s properties like `.name` can still be mutated);
keep the existing calls to `cntxMenu.register()` and all referenced symbols
(`Spicetify.ContextMenu.Item`, `toggleThrow`, `shouldAddContextMenu`,
`trashbinIcon`) unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@Extensions/trashbin.js`:
- Around line 357-358: Change the binding for the context menu item from a
mutable variable to an immutable one: replace the `let cntxMenu = new
Spicetify.ContextMenu.Item(THROW_TEXT, toggleThrow, shouldAddContextMenu,
trashbinIcon);` declaration with a `const` so the binding is not reassigned (the
object’s properties like `.name` can still be mutated); keep the existing calls
to `cntxMenu.register()` and all referenced symbols
(`Spicetify.ContextMenu.Item`, `toggleThrow`, `shouldAddContextMenu`,
`trashbinIcon`) unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: ffa8b402-de30-4f1f-b704-42d6815ddb9c

📥 Commits

Reviewing files that changed from the base of the PR and between 919a019 and 5aff359.

📒 Files selected for processing (1)
  • Extensions/trashbin.js

}

const cntxMenu = new Spicetify.ContextMenu.Item(THROW_TEXT, toggleThrow, shouldAddContextMenu, trashbinIcon);
let cntxMenu = new Spicetify.ContextMenu.Item(THROW_TEXT, toggleThrow, shouldAddContextMenu, trashbinIcon);
Copy link
Member

Choose a reason for hiding this comment

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

cntxMenu is an object.

Suggested change
let cntxMenu = new Spicetify.ContextMenu.Item(THROW_TEXT, toggleThrow, shouldAddContextMenu, trashbinIcon);
const cntxMenu = new Spicetify.ContextMenu.Item(THROW_TEXT, toggleThrow, shouldAddContextMenu, trashbinIcon);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank You!

@rxri rxri changed the title fix(Extensions): fix trashbin context menu label not updating fix(trashbin): context menu label not updating Mar 22, 2026
@rxri rxri merged commit 7bd6df4 into spicetify:main Mar 22, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Text on Trashbin buttons doesn't change after an item has been added

2 participants