Skip to content

Conversation

@maribethb
Copy link
Contributor

@maribethb maribethb commented Apr 11, 2025

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.0 April 14, 2025 20:28
if (item.scopeType === ScopeType.COMMENT && !scope.comment) continue;
if (item.scopeType === ScopeType.WORKSPACE && !scope.workspace)
continue;
}
Copy link
Contributor Author

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
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 owner April 14, 2025 20:31
@maribethb maribethb 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.0 Apr 15, 2025
7 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking change Used to mark a PR or issue that changes our public APIs. PR: feature Adds a feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants