Skip to content

Fix crash on long-press when a placeholder is the only popup key#2619

Open
MiMoHo wants to merge 1 commit into
HeliBorg:mainfrom
MiMoHo:placeholder-popup-crash
Open

Fix crash on long-press when a placeholder is the only popup key#2619
MiMoHo wants to merge 1 commit into
HeliBorg:mainfrom
MiMoHo:placeholder-popup-crash

Conversation

@MiMoHo

@MiMoHo MiMoHo commented Jul 6, 2026

Copy link
Copy Markdown

Fixes #1324.

Problem

When a key has a placeholder popup as its only popup key, and the popup key order is set so that only "Layout" popups are used, long-pressing the key crashes the keyboard.

Reproduction (from #1324):

{ "label": "", "popup": { "relevant": [ { "type": "placeholder" } ] } }
  1. Use a layout with such a key.
  2. Settings → set popup key order to "Layout" only.
  3. Long-press the key.

Cause

createPopupKeysArray produces a non-empty array for the placeholder, but the placeholder resolves to an empty string. After PopupKeySpec.filterOutEmptyString(...) removes it, the result is an empty (but non-null) array. Key.KeyParams then still sets ACTION_FLAGS_ENABLE_LONG_PRESS, so a long-press opens a popup keyboard with zero keys, which throws in PopupKeysKeyboard.Builder (division by / layout for zero columns).

Fix

Only enable long-press / build mPopupKeys when the filtered array is actually non-empty:

if (finalPopupKeys != null && finalPopupKeys.length > 0) {

This makes a placeholder-only popup set behave like "no popups", matching the expected behaviour described in the issue (long-press does nothing instead of crashing).

Tests

Added two tests to ParserTest:

  • placeholderAsOnlyPopup – a placeholder-only popup set yields mPopupKeys == null and long-press disabled (this crashed before the fix).
  • placeholderNextToOtherPopup – a placeholder alongside a real popup key keeps only the real key.

All unit tests pass (testRunTestsUnitTest).

…ceholders

A key with a placeholder as its only popup key (with popup key order
containing only "layout") resulted in an empty but non-null popup key
array, enabling long press that then crashes in
PopupKeysKeyboard.Builder with a division by zero.

fixes HeliBorg#1324

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

Keyboard Crashes When Placeholder Popup Key Is the Only Configured Popup

1 participant