feat: improved insertion flow#455
feat: improved insertion flow#455rachel-fenichel merged 12 commits intoRaspberryPiFoundation:mainfrom rachel-fenichel:clean-insert-then-move
Conversation
|
'M' then 'Escape' on an existing statement block now moves the cursor between that block and the previous block which is a regression. Even weirder if you move it before cancelling as the connection location is based on where the preview was shown not where it moves back to on cancel. For a value block (e.g. test in |
|
Sorry, will need to take a look at this tomorrow. There's a lot of context that I don't know here that I'll need to familiarize myself with in order to do an effective review. Feel free to redirect to someone who has more context if that's preferable, but otherwise I will take a pass tomorrow (likely in the early afternoon PT). |
microbit-matt-hillsdon
left a comment
There was a problem hiding this comment.
Keen to get this one merged. It looks good from my perspective except for the one note I added previously re cancelling a move of a preexisting block. I've added a suggested fix.
@rachel-fenichel there's also your note in the PR description about the lack of need to unpatch the dragger as it's recreated. So that's potentially some easy simplification.
src/actions/mover.ts
Outdated
There was a problem hiding this comment.
This seems a straightforward fix for my feedback:
| if (target) { | |
| if (dragStrategy.isNewBlock && target) { |
If we go ahead with removing connection positions then the code in the block will likely need a tweak too, but let's get this in ahead of thinking about that.
BenHenning
left a comment
There was a problem hiding this comment.
Apologies for the delayed review. I had a few comments, but they're largely nits so going ahead and approving.
The solutions make sense to me, though admittedly I don't grok the complete dragging context. :)
| workspace.setResizesEnabled(false); | ||
| Events.setGroup(true); | ||
| const existingGroup = Events.getGroup(); | ||
| if (!existingGroup) { |
There was a problem hiding this comment.
Maybe add a line comment here explaining why this is important (otherwise the context feels maybe a bit hidden).
There was a problem hiding this comment.
Added a short comment. This is also a pattern in all of Blockly.
src/navigation.ts
Outdated
There was a problem hiding this comment.
Is this correct? Seems like it should be tied to whether the connection was successful (per insertBlock's docs), not anything about keys.
| callback: (workspace) => this.mover.startMove(workspace), | ||
| preconditionFn: (workspace) => { | ||
| const startBlock = this.getCurrentBlock(workspace); | ||
| return !!startBlock && this.mover.canMove(workspace, startBlock); |
There was a problem hiding this comment.
Why not just startBlock && ...? '!!' seems unnecessary here. Ditto below in a few places.
There was a problem hiding this comment.
Needs to return a boolean, not null, and the compiler yelled.
src/actions/move.ts
Outdated
There was a problem hiding this comment.
I'm assuming the truthy check for block here is because TypeScript doesn't realize that it's impossible for it to ever be null or undefined?
If it's null inference is actually good enough to detect that, you should be able to drop that part of the condition.
src/keyboard_drag_strategy.ts
Outdated
There was a problem hiding this comment.
Won't setCurNode guarantee selection? It'd be nice to consolidate since otherwise every setSelected() needs to be reconsidered for focus.
There was a problem hiding this comment.
Removed setSelected
src/keyboard_drag_strategy.ts
Outdated
There was a problem hiding this comment.
This seems worthwhile to maybe file an issue for and point to it.
There was a problem hiding this comment.
Filed #471 and removed the comment here because it's a general problem as described by the issue, this is just an instance of it.
|
@gonfunko please take a look--I fixed the issues Ben identified + accepted Matt's suggested patch. I think the tests failing are the ones that Erik is currently working on/investigating. |
|
Retested manually and with automated tests after RaspberryPiFoundation/blockly#8933 and it still works, so I'm merging now. |
cedde35
into
RaspberryPiFoundation:main
Fixes #421
Based on #438
This is intended to be reviewed one commit at a time; each commit is small.
Behaviour after change
Escapedeletes the newly inserted block.Escapeputs the cursor at the last target connection, (if any).Additional information
This is largely the change that @microbit-matt-hillsdon made, rebased onto main.
I had a grand plan to do all the work to find the
insertStartPointinKeyboardDragStrategyinstead of having to pass it into the drag strategy. That's the reason that I started by passing the block andisNewBlockinto the drag strategy. This idea failed becausegetStationaryNodemust be called before creating the new block, to avoid updating the cursor. I could pass the stationary node into the drag strategy instead of the start point, but in both cases I'm doing layer bypass to move information around. So that was a dud.A few changes:
startMove, instead of expecting the mover to find it by looking at the cursor.startMove.