From 770336d0cfe6a68befd594ea4d04b0e5bc581ac5 Mon Sep 17 00:00:00 2001 From: snowykte0426 Date: Tue, 18 Aug 2026 14:08:14 +0900 Subject: [PATCH] fix(recipient-completion): show which suggestion the keyboard has selected Moving through the recipient completion list with a keyboard left no trace on screen, so there was no way to tell which suggestion was about to be picked. The list selector cannot do this reliably. `setListSelection()` reaches `ListView.layoutChildren`, which positions the selector with `positionSelector(INVALID_POSITION, sel)`; `AbsListView.positionSelector` then computes `positionChanged = position != mSelectorPosition` and skips the block that refreshes the selector's drawable state, because both sides are -1. The selector is therefore painted with an empty state set on the first selection. Its state is the list's own state as well, and `DropDownListView` reports itself as focused for as long as the popup exists, so a stateful selector cannot tell a selected row from a cleared one either. The row does not have that problem: `ListView.setupChild` calls `child.setSelected(selected && shouldShowSelector())`, which is correct from the first selection onwards. So give the row a background that draws the selection, and leave the list selector alone so touch feedback is unchanged. `colorSecondaryContainer`, the Material token for a selected list item, is not usable here: the rows take their text colour from `textColorPrimaryRecipientDropdown`, which is `@android:color/primary_text_light` and pinned to black in the light theme, and that only reaches 3.3:1 on `lightSecondaryContainer`. `colorSurfaceContainerHighest` keeps the text at 16:1 but is itself only 1.22:1 against the popup background, so the selected row also gets a `colorPrimary` outline: 7.7:1 in the light theme and 14.1:1 in the dark one, which meets WCAG 1.4.11 for a state indicator. This has no visible effect on its own. The completion list ignores the arrow keys until something is selected, so #11413, which makes the tab key select the first suggestion, is what reaches this code path. --- .../recipient_dropdown_item_background.xml | 39 +++++++++++++++++++ .../res/layout/recipient_dropdown_item.xml | 1 + 2 files changed, 40 insertions(+) create mode 100644 legacy/ui/legacy/src/main/res/drawable/recipient_dropdown_item_background.xml diff --git a/legacy/ui/legacy/src/main/res/drawable/recipient_dropdown_item_background.xml b/legacy/ui/legacy/src/main/res/drawable/recipient_dropdown_item_background.xml new file mode 100644 index 00000000000..2a4ce37bc0d --- /dev/null +++ b/legacy/ui/legacy/src/main/res/drawable/recipient_dropdown_item_background.xml @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + diff --git a/legacy/ui/legacy/src/main/res/layout/recipient_dropdown_item.xml b/legacy/ui/legacy/src/main/res/layout/recipient_dropdown_item.xml index 9a0f00442d8..3e42f23f1e6 100644 --- a/legacy/ui/legacy/src/main/res/layout/recipient_dropdown_item.xml +++ b/legacy/ui/legacy/src/main/res/layout/recipient_dropdown_item.xml @@ -8,6 +8,7 @@ android:minHeight="?android:listPreferredItemHeight" android:gravity="center" android:orientation="horizontal" + android:background="@drawable/recipient_dropdown_item_background" >