Conversation
…ves at non-default zoom levels
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
Proposed Changes
This PR backports the support for moving blocks, workspace comments, and bubbles using the keyboard from the blockly-keyboard-experimentation repo to core Blockly. These interactions have been proved out through user testing, and are an important foundational aspect of making Blockly more accessible. Toward this end, the following changes have been made:
IDragger,IDraggableandIDragStrategyinterfaces have been revised to put less of an emphasis on mouse events and clean up some other issues that using them in practice has revealed. See the Breaking Changes section below for more details.KeyboardMoverclass has been introduced. An instance of this class is owned byWorkspaceSvg, and is used to coordinate keyboard-driven movement between keyboard shortcuts and the dragging system.Future Work
At present, it is not possible to insert blocks from the flyout using the keyboard. This is now feasible, but in the interest of avoiding scope creep and preventing this PR from becoming even larger I will include it in a followup PR.
Additionally, the remaining functionality from the blockly-keyboard-experimentation repo still needs to be backported to core.
Test Coverage
Tests have been added that exercise each kind of built-in movable entity (blocks, workspace comments, and bubbles). Additionally, the test suite for constrained movement of blocks from the blockly-keyboard-experimentation repo has been backported.
Breaking Changes
If your application has custom code that implements the
IDragger,IDraggable, orIDragStrategyinterfaces, you may need to make some changes. Specifically:IDragStrategy.startDrag()andIDraggable.startDrag()need to return anIDraggablethat the rest of the drag process will act on. Typically,IDraggables should just return themselves. In cases where you want a drag to act on a different element than the one the drag started on, you can return the object you actually want the drag to act on.PointerEventnow need to handle receiving aPointerEvent | KeyboardEvent. In keyboard-driven drags, this will be aKeyboardEvent.IDraggernow need to implementIDragger.onDragRevert(). This method differs fromonDragEnd()in that it is invoked when a drag is cancelled or reverted by the user; generally, the item being dragged should be moved back to its starting position. If a drag is reverted,onDragEnd()will still be invoked afteronDragRevert()has been called, so common cleanup can be reliably handled there.IDraggerhave been made optional, consistent withIDraggableandIDragStrategy. Your code should not rely on them being present, although they typically will be for both mouse- and keyboard-driven drags.