Skip to content

feat!: deprecate scopeType and include focusedNode in context menu options - #8882

Merged
maribethb merged 2 commits into
RaspberryPiFoundation:rc/v12.0.0from
maribethb:scope
Apr 15, 2025
Merged

feat!: deprecate scopeType and include focusedNode in context menu options#8882
maribethb merged 2 commits into
RaspberryPiFoundation:rc/v12.0.0from
maribethb:scope

Conversation

@maribethb

@maribethbmaribethb commented Apr 11, 2025

Copy link
Copy Markdown
Contributor

The basics

The details

Resolves

Fixes#8838 and works on #8839 - the latter can be closed once the work on IFocusableNode has settled a bit more and we can remove any from the type in Scope here. Currently it can't be removed because BlockSvg and friends don't actually implement that interface yet (Ben has a PR in progress).

Proposed Changes

  • Makes scopeType optional in ContextMenuItem API
  • Changes getContextMenuOptions to no longer accept a scopeType parameter
  • Adds focusedNode to Scope type

Reason for Changes

  • Makes context menu more flexible by getting rid of the scope type enum and allowing context menu options on any object that can be focused

Breaking Changes

This is only a breaking change if you call ContextMenuRegistry.registry.getContextMenuOptions. The other changes in this PR are backwards-compatible with your existing registered context menu items, though you may wish to read the documentation and update them to the new API.

If you do call getContextMenuOptions, update your usage to no longer pass the scopeType param, and include the object that is having its menu opened in the scope.focusedNode property. See the implementations in this PR for examples.

@maribethb
maribethb changed the base branch from action-menu to rc/v12.0.0April 14, 2025 20:28
if (item.scopeType === ScopeType.COMMENT && !scope.comment) continue;
if (item.scopeType === ScopeType.WORKSPACE && !scope.workspace)
continue;
}

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

github is not showing a good diff, the only difference from this point on is that the if statement ends here and everything else is unindented correspondingly

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Much better with Hide Whitespace on:
image

@maribethb
maribethb marked this pull request as ready for review April 14, 2025 20:31
@maribethb
maribethb requested a review from a team as a code ownerApril 14, 2025 20:31
@maribethbmaribethb added breaking change Used to mark a PR or issue that changes our public APIs. PR: feature Adds a feature labels Apr 14, 2025
@maribethb
maribethb merged commit acca9ea into RaspberryPiFoundation:rc/v12.0.0Apr 15, 2025
@maribethb
maribethb deleted the scope branch July 7, 2026 20:14
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking changeUsed to mark a PR or issue that changes our public APIs.PR: featureAdds a feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@maribethb@gonfunko@rachel-fenichel