From 5b5c2e936470fd4339228417bc8f480b3698f0d4 Mon Sep 17 00:00:00 2001 From: MiMoHo <37556964+MiMoHo@users.noreply.github.com> Date: Fri, 24 Jul 2026 01:23:45 +0200 Subject: [PATCH] Return to the base layout when closing a numpad/D-pad overlay Numpad and D-pad are sibling overlays; switching directly between them pushed the current one onto the previous-layout stack, so closing the newly shown overlay returned to the OTHER overlay instead of the layout they were opened over (usually the alphabet). Switch directly without stacking for a deliberate (non-sliding) numpad<->dpad change. Co-Authored-By: Claude Opus 4.8 --- .../helium314/keyboard/keyboard/internal/KeyboardState.kt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/src/main/java/helium314/keyboard/keyboard/internal/KeyboardState.kt b/app/src/main/java/helium314/keyboard/keyboard/internal/KeyboardState.kt index 08008c24c2..574940c49a 100644 --- a/app/src/main/java/helium314/keyboard/keyboard/internal/KeyboardState.kt +++ b/app/src/main/java/helium314/keyboard/keyboard/internal/KeyboardState.kt @@ -198,6 +198,13 @@ class KeyboardState(private val switchActions: SwitchActions) { } if (mode == layout.mode()) { loadPreviousLayout(autoCapsFlags, recapitalizeMode) + } else if (!isInLayoutSlide && (mode == Mode.NUMPAD || mode == Mode.DPAD) && (layout == Utility.NUMPAD || layout == Utility.DPAD)) { + // numpad and dpad are sibling overlays: switching directly from one to the other must not + // push onto the previous-layout stack, otherwise closing the new overlay would fall back to + // the other overlay instead of the layout they were both opened over (usually the alphabet). + // only for a deliberate (non-sliding) switch: while sliding, the tail below pops the pushed + // entry, so we must take the regular setLayout path to keep that accounting balanced. + loadLayout(layout) } else { setLayout(layout) }