-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
feat!: Added support for separators in menus. #8767
Conversation
); | ||
} else if (typeof tuple[1] !== 'string') { | ||
} else if (typeof option[1] !== 'string') { |
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.
Won't this fail if the option is just FieldDropdown.SEPARATOR
instead of a tuple?
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.
No; option[1]
would be "e"
in that case, since option
would be the string "separator", and the type of "e" is still string
.
@@ -35,14 +36,10 @@ import {Svg} from './utils/svg.js'; | |||
* Class for an editable dropdown field. | |||
*/ | |||
export class FieldDropdown extends Field<string> { | |||
/** Horizontal distance that a checkmark overhangs the dropdown. */ |
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.
Why remove these two?
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.
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.
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
ContextMenuOption
andRegistryItem
are nowtype
s instead ofinterface
s. 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 thatimplements
either of these interfaces, theimplements
will need to be removed.