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 #8063
Proposed Changes
getContents
method to theIFlyout
interface (breaking change)Flyout
andFlyoutItem[]
getContents
method inflyout_base
to return an actualFlyoutItem[]
instead of saying it does that, but is actuallyArray<Block | FlyoutItem>
(note that this method exists in develop but hasn't been released yet so this isn't the breaking change)Reason for Changes
show
is called, the flyout definition is passed to the method, that definition is parsed, and the blocks, buttons, and gaps are laid out in the flyout. The actual blocks and buttons created are never stored anywhere.getContents
method was only added to the abstractFlyout
class, and not theIFlyout
interface. However, custom flyouts are only required to implement theIFlyout
interface and are not required to extend our base class.getContents
method was typed as returning an array ofFlyoutItem
s, but it didn't actually return those, and used casts to fake it, both when setting the contents and using them. The reason I'm fixing this by actually usingFlyoutItem
instead of just changing the type is because usingFlyoutItem
is more future-compatible. If we ever extend the flyout definition to include a third type of object that might be keyboard-navigable, we won't need to change the type or implementation ofgetContents
(just the implementation ofASTNode
to handle the new item).Test Coverage
I haven't been able to link this to samples to test keyboard navigation, but I'll try that again before submitting this PR.
Documentation
N/A, we don't document how to create a custom flyout at this time.
Breaking changes / To fix
getContents
is now required to be implemented in theIFlyout
interface. This is important to support our goal of improving accessibility in Blockly.Blockly.Flyout
,Blockly.HorizontalFlyout
,Blockly.VerticalFlyout
, or theContinuousFlyout
from the continuous-toolbox plugin, you may not need to take any action. ThegetContents
method has been implemented in the abstract base class.show
method, ensure that it sets thecontents
property of the flyout as the base class implementation does.IFlyout
interface and does not extend the abstractFlyout
class, you will need to add an implementation forgetContents
to your flyout. This method should return a list of allFlyoutItem
s (at this time, that includesBlock
s andFlyoutButton
s) that are present in the current flyout.