Skip to content

fix: Use dominant axis for keyboard move direction#10030

Open
microbit-robert wants to merge 1 commit into
RaspberryPiFoundation:mainfrom
microbit-robert:keyboard-move-direction
Open

fix: Use dominant axis for keyboard move direction#10030
microbit-robert wants to merge 1 commit into
RaspberryPiFoundation:mainfrom
microbit-robert:keyboard-move-direction

Conversation

@microbit-robert

@microbit-robert microbit-robert commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

The basics

The details

Resolves

In keyboard move mode, getDirectionToNewLocation decided the move direction by testing the horizontal delta before the vertical one and treating any non-zero x as a sideways move. The move delta is round-tripped through pixels (KeyboardMover scales up by the workspace scale, Dragger scales back down), and at any zoom other than 100% that conversion leaves ~1e-14 of floating-point residue on the axis that should be exactly zero. In real terms, x could be 0.0...01 and y could be ~20, but because we checked x first, it was interpreted as a horizontal move rather than vertical. At a scale of 1, the conversions are exact, so there is no floating point result.

Fixes #10029

Proposed Changes

Choose the axis with the larger absolute delta instead, so the genuine movement always wins and sub-pixel rounding noise can't flip the direction. Behaviour at scale 1 is unchanged.

Reason for Changes

This addresses unexpected keyboard move behaviour raised in #10029

Test Coverage

This could do with a test case or two, but it's not straight forward to reproduce so would need quite a complicated test setup

Documentation

N/A

Additional Information

Behaviour after change:
https://github.com/user-attachments/assets/e3a12b98-5651-4f4a-9bd1-7f727fcb078b

@microbit-robert microbit-robert requested a review from a team as a code owner June 18, 2026 11:01
@github-actions github-actions Bot added PR: fix Fixes a bug and removed PR: fix Fixes a bug labels Jun 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: fix Fixes a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Keyboard moves can sometimes be confusing when the workspace scale is not 1

2 participants