feat!: Added support for separators in menus.#8767
Merged
gonfunko merged 3 commits intoRaspberryPiFoundation:rc/v12.0.0from Feb 27, 2025
Merged
feat!: Added support for separators in menus.#8767gonfunko merged 3 commits intoRaspberryPiFoundation:rc/v12.0.0from
gonfunko merged 3 commits intoRaspberryPiFoundation:rc/v12.0.0from
Conversation
| the string literal 'separator'. Found: ${option}`, | ||
| ); | ||
| } else if (typeof tuple[1] !== 'string') { | ||
| } else if (typeof option[1] !== 'string') { |
Collaborator
There was a problem hiding this comment.
Won't this fail if the option is just FieldDropdown.SEPARATOR instead of a tuple?
Contributor
Author
There was a problem hiding this comment.
No; option[1] would be "e" in that case, since option would be the string "separator", and the type of "e" is still string.
| * Class for an editable dropdown field. | ||
| */ | ||
| export class FieldDropdown extends Field<string> { | ||
| /** Horizontal distance that a checkmark overhangs the dropdown. */ |
Collaborator
There was a problem hiding this comment.
Why remove these two?
Contributor
Author
There was a problem hiding this comment.
They're unreferenced in the entire codebase. I suppose this is technically a breaking change, but they feel very implementation detail-y. Happy to revert if you want though.
rachel-fenichel
approved these changes
Feb 27, 2025
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The basics
The details
Resolves
Fixes #8752
Proposed Changes
This PR adds support for separators in all Blockly menus, including contextual menus on the workspace, blocks and comments, and in dropdown menus spawned from
FieldDropdown.For contextual menus, separators can be added via the context menu registry in a similar manner to normal menu items:
For
FieldDropdown, separators can be added via JSON (or a generator function) by using the string literalseparator:Breaking changes
In general existing code should continue to work, but in order to accomodate typings
ContextMenuOptionandRegistryItemare nowtypes instead ofinterfaces. Core and our documentation suggest using these as object literals, as in the example above in this PR description, which will continue to work as-is, but if users have a class thatimplementseither of these interfaces, theimplementswill need to be removed.