Skip to content

fix(shortcut-row): align down-swipe popup to the source letter row (#36)#58

Merged
AsafMah merged 2 commits into
devfrom
fix/shortcut-bottom-popup-align
Jun 7, 2026
Merged

fix(shortcut-row): align down-swipe popup to the source letter row (#36)#58
AsafMah merged 2 commits into
devfrom
fix/shortcut-bottom-popup-align

Conversation

@AsafMah

@AsafMah AsafMah commented Jun 6, 2026

Copy link
Copy Markdown
Owner

Fixes #36 — the down-swipe shortcut popup misalignment. Verified on-device (S24+).

Root cause (the real one: horizontal)

The popup re-anchored on the swiped key: PopupKeysKeyboard.Builder splits the icons left/right of the key based on the key's absolute x in the full keyboard (maxLeftKeys = coordXInParent / keyWidth). The bottom letter row is inset by the shift key on the left (and bounded by backspace on the right), so the leftmost letter z sits well right of x=0 → the split reserved left-side columns and placed icons over the shift area. Result: swiping down on z landed on a middle/right icon instead of the far-left one. The top row starts at x≈0, so it looked correct — hence the top/bottom asymmetry (exactly the “shift/backspace irregular keys” hunch in the issue).

Fix

Pin the shortcut popup's visible content left edge to the source letter row's left edge (leftmost normal key in the swiped row), so the icons tile across the row and each letter maps to the icon directly above it (z→1st … m→7th), draggable sideways. Threaded via a rowAlignedLeftX argument + setRowAlignedLeftX(...); normal long-press popups are unchanged (NO_ROW_ALIGN sentinel — they still anchor on the key).

The earlier commit in this PR also makes the below-key vertical placement explicit (setShowBelowAnchor, anchoring the panel top to the key bottom) so the popup sits flush below the row.

Verification

  • Compiles (offline + standard flavors).
  • On-device (S24+): confirmed — swipe-down on each bottom-row letter now selects the icon above it; up-swipe unchanged.
  • Popup geometry isn't JVM-unit-coverable, so this rests on the device test.

Note

Icon width is the keyboard's natural key width; for the standard 7-letter row + 7 icons it tiles 1:1. If a layout's row key-count ≠ icon count, the left edge still aligns and it degrades gracefully (exact row-width tiling could be a follow-up).

AsafMah added 2 commits June 6, 2026 15:27
The below-key (down-swipe) shortcut popup reused the above-key placement
formula in PopupKeysKeyboardView.showPopupKeysPanelInternal, compensated by a
+container.getMeasuredHeight() hack in MainKeyboardView. That left the bottom
popup with the wrong vertical gap/overlap vs the top one.

Make the placement below-aware: setShowBelowAnchor() selects a mirrored
y-formula that anchors the panel's visible content top to pointY (vs bottom for
the above case), and MainKeyboardView passes pointY = key bottom directly.
Horizontal anchoring is unchanged (already symmetric).

Closes #36.
The real misalignment was horizontal, not vertical: the popup re-anchored on the
swiped key via PopupKeysKeyboard's left/right split, which keys the split off the
key's absolute x in the full keyboard. The bottom letter row is inset by the shift
key (and bounded by backspace), so the leftmost letter (z) sits well right of x=0
and the icons got placed over the shift area — swiping down on z landed on a
middle/right icon instead of the far-left one. The top row starts at x~0 so it
looked fine, producing the top/bottom asymmetry.

Fix: pin the shortcut popup's visible content left edge to the source letter row's
left edge (leftmost normal key), so the 7 icons tile across the row and each letter
maps to the icon directly above it (z->1st ... m->7th), draggable sideways. Normal
long-press popups are unchanged (NO_ROW_ALIGN sentinel; they still anchor on the key).
Verified on-device (S24+).
@AsafMah AsafMah changed the title fix(shortcut-row): align down-swipe popup below source key (#36) fix(shortcut-row): align down-swipe popup to the source letter row (#36) Jun 7, 2026
@AsafMah
AsafMah merged commit 09e027c into dev Jun 7, 2026
1 check passed
AsafMah added a commit that referenced this pull request Jun 7, 2026
…row (#36) (#68)

Follow-up to #58: the left-pin used natural icon width, so N icons tiled from the
left and the far-right keys couldn't reach them. Now each icon is sized to
rowWidth/iconCount (usable normal-key row span), so the N icons tile the whole row
and a swipe maps proportionally — swiping from the i-th 1/N of the row selects the
i-th icon. Threads a fixedKeyWidth into PopupKeysKeyboard.Builder (0 = default for
normal/emoji popups); dividers are dropped in that mode so the icons tile exactly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant