Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 3.9k
fix: Synchronize gestures and focus#8981
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
Merged
BenHenning
merged 8 commits into
RaspberryPiFoundation:rc/v12.0.0
from
BenHenning:synchronize-gestures-and-focusMay 5, 2025
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
4048576
fix: set focus from clicks
rachel-fenichel 7449d87
fix: remove outline on focused nodes and reselect blocks
rachel-fenichel d27af3f
Merge branch 'rc/v12.0.0' into focus-click
BenHenning 8bf37ac
fix: Ensure gestures & focus synchronize.
BenHenning 54950c4
chore: revert file + try lower delay.
BenHenning 646e943
chore: fix comment
BenHenning 2d88ff5
Merge branch 'rc/v12.0.0' into synchronize-gestures-and-focus
BenHenning 9199866
Use finishQueuedRenders instead of setTimeout.
BenHenning File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -25,6 +25,7 @@ import * as dropDownDiv from './dropdowndiv.js'; | ||
| import {EventType} from './events/type.js'; | ||
| import * as eventUtils from './events/utils.js'; | ||
| import type {Field} from './field.js'; | ||
| import {getFocusManager} from './focus_manager.js'; | ||
| import type {IBubble} from './interfaces/i_bubble.js'; | ||
| import {IDraggable, isDraggable} from './interfaces/i_draggable.js'; | ||
| import {IDragger} from './interfaces/i_dragger.js'; | ||
| @@ -289,7 +290,7 @@ export class Gesture { | ||
| // The start block is no longer relevant, because this is a drag. | ||
| this.startBlock = null; | ||
| this.targetBlock = this.flyout.createBlock(this.targetBlock); | ||
| common.setSelected(this.targetBlock); | ||
| getFocusManager().focusNode(this.targetBlock); | ||
| return true; | ||
| } | ||
| return false; | ||
| @@ -734,6 +735,7 @@ export class Gesture { | ||
| this.startComment.showContextMenu(e); | ||
| } else if (this.startWorkspace_ && !this.flyout) { | ||
| this.startWorkspace_.hideChaff(); | ||
| getFocusManager().focusNode(this.startWorkspace_); | ||
| this.startWorkspace_.showContextMenu(e); | ||
| } | ||
| @@ -762,9 +764,12 @@ export class Gesture { | ||
| this.mostRecentEvent = e; | ||
| if (!this.startBlock && !this.startBubble && !this.startComment) { | ||
| // Selection determines what things start drags. So to drag the workspace, | ||
| // we need to deselect anything that was previously selected. | ||
| common.setSelected(null); | ||
| // Ensure the workspace is selected if nothing else should be. Note that | ||
| // this is focusNode() instead of focusTree() because if any active node | ||
| // is focused in the workspace it should be defocused. | ||
| getFocusManager().focusNode(ws); | ||
| } else if (this.startBlock) { | ||
| getFocusManager().focusNode(this.startBlock); | ||
| } | ||
| this.doStart(e); | ||
| @@ -865,13 +870,18 @@ export class Gesture { | ||
| ); | ||
| } | ||
| // Note that the order is important here: bringing a block to the front will | ||
| // cause it to become focused and showing the field editor will capture | ||
| // focus ephemerally. It's important to ensure that focus is properly | ||
| // restored back to the block after field editing has completed. | ||
| this.bringBlockToFront(); | ||
| // Only show the editor if the field's editor wasn't already open | ||
| // right before this gesture started. | ||
| const dropdownAlreadyOpen = this.currentDropdownOwner === this.startField; | ||
| if (!dropdownAlreadyOpen) { | ||
| this.startField.showEditor(this.mostRecentEvent); | ||
| } | ||
| this.bringBlockToFront(); | ||
| } | ||
| /** Execute an icon click. */ | ||
| @@ -901,6 +911,9 @@ export class Gesture { | ||
| const newBlock = this.flyout.createBlock(this.targetBlock); | ||
| newBlock.snapToGrid(); | ||
| newBlock.bumpNeighbours(); | ||
| // If a new block was added, make sure that it's correctly focused. | ||
| getFocusManager().focusNode(newBlock); | ||
| } | ||
| } else { | ||
| if (!this.startWorkspace_) { | ||
| @@ -928,11 +941,7 @@ export class Gesture { | ||
| * @param _e A pointerup event. | ||
| */ | ||
| private doWorkspaceClick(_e: PointerEvent) { | ||
| const ws = this.creatorWorkspace; | ||
BenHenning marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| if (common.getSelected()) { | ||
| common.getSelected()!.unselect(); | ||
| } | ||
| this.fireWorkspaceClick(this.startWorkspace_ || ws); | ||
| this.fireWorkspaceClick(this.startWorkspace_ || this.creatorWorkspace); | ||
| } | ||
| /* End functions defining what actions to take to execute clicks on each type | ||
| @@ -947,6 +956,8 @@ export class Gesture { | ||
| private bringBlockToFront() { | ||
| // Blocks in the flyout don't overlap, so skip the work. | ||
| if (this.targetBlock && !this.flyout) { | ||
| // Always ensure the block being dragged/clicked has focus. | ||
| getFocusManager().focusNode(this.targetBlock); | ||
| this.targetBlock.bringToFront(); | ||
| } | ||
| } | ||
| @@ -1023,7 +1034,6 @@ export class Gesture { | ||
| // If the gesture already went through a bubble, don't set the start block. | ||
| if (!this.startBlock && !this.startBubble) { | ||
| this.startBlock = block; | ||
| common.setSelected(this.startBlock); | ||
| if (block.isInFlyout && block !== block.getRootBlock()) { | ||
| this.setTargetBlock(block.getRootBlock()); | ||
| } else { | ||
| @@ -1046,6 +1056,7 @@ export class Gesture { | ||
| this.setTargetBlock(block.getParent()!); | ||
| } else { | ||
| this.targetBlock = block; | ||
| getFocusManager().focusNode(block); | ||
| } | ||
| } | ||
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
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.
Uh oh!
There was an error while loading. Please reload this page.