rfellows opened a new pull request, #11561:
URL: https://github.com/apache/nifi/pull/11561

   ## Summary
   
   Fixes [NIFI-16222](https://issues.apache.org/jira/browse/NIFI-16222): when a 
searchable select renders **grouped** options, keyboard navigation still 
highlighted rows but failed to scroll the active option into view and failed to 
select on Enter. Ungrouped searchable selects were unaffected; mouse selection 
continued to work.
   
   ## Root cause
   
   Grouped, non-virtual templates emit **group-scoped** option element ids 
(`groupId-optIdx`), while keyboard scroll and Enter selection looked up options 
using the **flat** active index id. The highlighted row’s DOM id never matched 
what scroll/`getElementById` and Enter selection expected, so:
   
   - Arrow navigation could move the highlight off-screen without scrolling
   - Enter could not resolve the highlighted option for selection
   
   ## Changes
   
   Limited to `nifi-frontend` shared `searchable-select`:
   
   - Tag the active option with a stable `activeOptionId`
     - Grouped: driven by `activeOptionRef` (option object identity) so 
duplicate values across groups mark exactly one row
     - Ungrouped: driven by `activeTemplateIndex`
   - Scroll into view via `activeOptionId` after change detection so the id is 
present in the DOM before lookup
   - Enter selects through the matching `MatOption` via 
`_selectViaInteraction()` (same user-input path Material uses for a click), 
with a non-ghost value fallback when needed
   - Disarm `_allowNextValueChange` on Escape, panel close, and Enter on an 
already-selected option so closed-panel arrow auto-select cannot leak through 
as an intentional change
   - Grouped `@for` tracking uses option object identity (values may not be 
unique)
   - Document that **grouped + virtual + duplicate values** remains unsupported 
(value-based virtual highlight)
   
   ## Why this is safe / low regression risk
   
   - **Blast radius**: changes target the non-virtual keyboard path (scroll + 
Enter + nav reset). Mouse selection and ungrouped keyboard behavior are 
preserved; virtual scrolling is unchanged aside from documenting the existing 
grouped/duplicate limitation.
   - **Same Material path as click**: Enter goes through 
`MatOption._selectViaInteraction()`, so multi-select toggle and `(valueChange)` 
flow match a real user click rather than a synthetic DOM click / flat-id scheme.
   - **Ghost exclusion**: Enter resolution filters ghost options before value 
fallback, avoiding accidental selection of placeholder/ghost rows when a value 
is missing from an async batch.
   - **Async option batches**: navigation state (including `activeOptionRef`) 
resets when options are replaced, so stale highlights cannot select the wrong 
row after a batch update.
   - **Duplicate-value safety (non-virtual grouped)**: reference identity 
ensures a single `activeOptionId` and a deterministic Enter target when the 
same value appears in more than one group.
   - **Quality gates**: searchable-select suite is **126** specs, including new 
coverage for grouped scroll/Enter, multi-select, duplicate values, 
Escape/panel-close disarm, async batch replace, and ghosts. Shared frontend 
suite green as applicable before merge.
   
   ### Residual notes for reviewers
   
   - **Private Material API**: `_selectViaInteraction` is private. It is the 
canonical “user selected this option” entry point (`select()`/`deselect()` skip 
user-input / multi-select toggle semantics). Material/CDK bumps should re-run 
this suite; the Enter specs are the tripwire if that method changes or 
disappears.
   - **Known unsupported combo**: grouped + virtual scrolling with duplicate 
values across groups remains unsupported (documented on the input and covered 
by a documenting test). No current usage is expected to combine them.
   
   ## Test plan
   
   - [ ] Open a connector configuration / property UI that uses a searchable 
select with **grouped** options (e.g. secrets / credential-style property with 
group headers)
   - [ ] Open the dropdown, focus search, Arrow Down until the highlight would 
leave the visible area — list scrolls to keep the active option in view
   - [ ] With a grouped option highlighted, press Enter — option is selected 
and panel closes (single-select)
   - [ ] Confirm mouse click selection of grouped options still works
   - [ ] Spot-check an **ungrouped** searchable select: arrows + Enter still 
behave as before
   - [ ] Optional: multi-select grouped list — Enter toggles the highlighted 
row without closing; second Enter toggles off the same row when values 
duplicate across groups


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to