Skip to content

feat(ui5-li-custom): enhance arrow key navigation - #12700

Merged
kgogov merged 9 commits into
mainfrom
list-item-custom-keyboard-navigation
Dec 9, 2025
Merged

kgogov merged 9 commits into
mainfrom
list-item-custom-keyboard-navigation

Conversation

@kgogov

@kgogov kgogov commented Nov 20, 2025 •

Copy link
Copy Markdown
Contributor

Overview

This PR introduces improved keyboard navigation capabilities for ui5-li-custom components within lists, enabling users to efficiently navigate between internal focusable elements across multiple list items.

Architecture Changes

  • Refactored navigation logic: Moved F7 and Arrow Up/Down keyboard navigation from ListItem to List component
  • Centralized control: List component now manages all list-level navigation behavior
  • Scoping-safe selectors: Uses attribute notation ([ui5-li], [ui5-li-custom]) instead of tag names for multi-framework compatibility
  • Cleaner separation: ListItem now only provides utility methods (_getFocusedElementIndex, _hasFocusableElements, _isFocusOnInternalElement, _focusInternalElement)

1. Arrow Key Navigation Between Internal Elements

  • Arrow Up/Down keys now navigate between same-index focusable elements across list items
  • Enables column-wise navigation through structured list content
  • Example: Pressing Arrow Down while focused on the first button in Item 1 moves focus to the first button in Item 2

Key capabilities:

  • Navigate between corresponding elements (e.g., button-to-button, link-to-link)
  • Automatically skip items without focusable elements (e.g., standard list items)
  • Works seamlessly across ui5-li-group boundaries
  • Handles items with varying numbers of focusable elements (index clamping)
  • Does nothing at list boundaries (first/last item)
  • Preserves existing F2/Tab navigation behavior

2. F7 Navigation with Position Memory

  • F7 toggles focus between list item container and internal focusable elements
  • Remembers the focused element position when navigating between list items
  • Shared state across all items in the same list via _lastFocusedElementIndex
  • Example: If you focus the second button in Item 1, exit with F7, move to Item 2, and press F7 again, it focuses the second button in Item 2

Behavior comparison:

  • F2: Simple navigation - always goes to first focusable element (no memory)
  • F7: Smart navigation - remembers last focused element position across items

3. Fixed Scroll Blocking Issue

  • List component no longer unconditionally prevents default scroll behavior on Arrow Down
  • _handleDown() properly checks if growing button should be focused before preventing default
  • Preserves browser scroll functionality when arrow keys don't trigger list navigation

4. Test Coverage

Added 6 comprehensive Cypress tests covering:

  • Basic arrow down/up navigation
  • Skipping standard list items
  • Navigation across group boundaries
  • Handling items with different element counts
  • Boundary conditions (first/last item)
  • F7 position memory across items

5. Demo Page

Added ListItemCustomArrowNavigation.html with 8 examples demonstrating:

  • Basic column navigation
  • Mixed custom/standard items
  • Group navigation
  • Varying element counts
  • Boundary cases
  • Real-world scenarios
  • Selection modes

Breaking Changes

None - this is a fully backward-compatible enhancement.

Jira: BGSOFUIPIRIN-6942
Fixes #11987

@ui5-webcomponents-bot

ui5-webcomponents-bot commented Nov 20, 2025 •

Copy link
Copy Markdown
Collaborator

🧹 Preview deployment cleaned up: https://pr-12700--ui5-webcomponents.netlify.app

@ui5-webcomponents-bot
ui5-webcomponents-bot temporarily deployed to preview November 20, 2025 12:53 Inactive
@ui5-webcomponents-bot
ui5-webcomponents-bot temporarily deployed to preview November 20, 2025 14:24 Inactive
@kgogov
kgogov force-pushed the list-item-custom-keyboard-navigation branch from 8d06bd6 to 324c292 Compare November 20, 2025 14:35
@ui5-webcomponents-bot
ui5-webcomponents-bot temporarily deployed to preview November 20, 2025 14:42 Inactive
@ui5-webcomponents-bot
ui5-webcomponents-bot temporarily deployed to preview November 20, 2025 15:01 Inactive
@kgogov
kgogov force-pushed the list-item-custom-keyboard-navigation branch from 034548d to 5f38de1 Compare November 24, 2025 14:23
@ui5-webcomponents-bot
ui5-webcomponents-bot temporarily deployed to preview November 24, 2025 14:30 Inactive
@kgogov
kgogov marked this pull request as ready for review November 24, 2025 14:55
@kgogov
kgogov force-pushed the list-item-custom-keyboard-navigation branch from 5f38de1 to 7d958d0 Compare November 24, 2025 15:44
@ui5-webcomponents-bot
ui5-webcomponents-bot temporarily deployed to preview November 24, 2025 15:50 Inactive
@kgogov
kgogov requested a review from kineticjs November 26, 2025 08:46
F7 key enables navigation between list item and internal focusable elements:
- If focus is on item level, moves focus to previously focused internal element (or first if none)
- If focus is on internal element, saves focus position and moves back to item level
- Add Cypress tests for F7 functionality
- Add test page for manual F7 validation

Jira: BGSOFUIPIRIN-6942
Related: #11987
Fixes TypeScript linter errors for awaiting non-Promise parent calls
F7 navigation now remembers the focused element position when
moving between list items. Pressing F7 focuses the element at
the same index that was previously focused in another item.

The List component stores a shared _lastFocusedElementIndex
property, and ListItem uses getTabbableElements to reliably
find focusable elements. Helper methods handle focusing by
index and updating the stored position.
…ents

Arrow Up/Down keys now navigate between same-index focusable elements
across list items when focus is inside the internal content of list items.
This allows users to navigate column-wise through structured list items.

Key features:
- Navigate between corresponding elements across items (e.g., first button
  to first button in next/previous item)
- Automatically skip items without focusable elements
- Works across ui5-li-group boundaries
- Preserves existing F2/F7/Tab navigation
- Only prevents default scroll when List handles the event (growing button)
Add comprehensive test page for arrow key navigation between
internal elements across list items. Includes 8 test examples
covering basic navigation, mixed items, groups, boundary cases,
selection modes, and nested lists.
Add cypress tests for arrow key navigation between internal elements
across list items. Tests cover basic navigation, skipping standard items,
group boundaries, varying element counts, and boundary conditions.
F7 and F2 navigation now checks if there are tabbable elements
inside the list item before handling the event. If no tabbable
elements exist (e.g., delete button with tabindex="-1"), the
event propagates to allow parent components like Tokenizer to
handle it with their custom logic.

This fixes interference with Tokenizer's F7 behavior while
maintaining correct navigation for custom list items.
…mponent

Move F7 and Arrow Up/Down keyboard navigation logic from ListItem to List
to centralize list-level navigation behavior and improve maintainability.

Changes:
- Move _handleF7 navigation logic from ListItem to List
- Move _navigateToAdjacentItem logic from ListItem to List
- Add _getClosestListItem helper in List using scoping-safe attribute selector
- ListItem now only provides utility methods: _getFocusedElementIndex,
  _hasFocusableElements, _isFocusOnInternalElement, _focusInternalElement
- Remove List reference from ListItem (_getList method removed)

This refactoring ensures navigation logic is in the appropriate component
and follows UI5 Web Components architectural patterns.
@kgogov
kgogov force-pushed the list-item-custom-keyboard-navigation branch from 7d958d0 to 2e72928 Compare December 9, 2025 10:08
@ui5-webcomponents-bot
ui5-webcomponents-bot temporarily deployed to preview December 9, 2025 10:15 Inactive
@ui5-webcomponents-bot
ui5-webcomponents-bot temporarily deployed to preview December 9, 2025 10:47 Inactive
@kgogov
kgogov merged commit f672e13 into main Dec 9, 2025
14 checks passed
@kgogov
kgogov deleted the list-item-custom-keyboard-navigation branch December 9, 2025 11:52
@ui5-webcomponents-bot
ui5-webcomponents-bot temporarily deployed to preview December 9, 2025 11:52 Inactive
@ui5-webcomponents-bot

Copy link
Copy Markdown
Collaborator

🎉 This PR is included in version v2.18.0-rc.0 🎉

The release is available on v2.18.0-rc.0

Your semantic-release bot 📦🚀

@ui5-webcomponents-bot

Copy link
Copy Markdown
Collaborator

🎉 This PR is included in version v2.18.0 🎉

The release is available on v2.18.0

Your semantic-release bot 📦🚀

kgogov added a commit that referenced this pull request Aug 13, 2026
Document the SAP Fiori "Intentional Edit Pattern" keyboard
interactions (F2 / F7 / Tab / Arrow Up/Down) that were shipped in
two prior changes but were not reflected in the JSDoc or on the
docs website. The gap led users to report the intended behavior as
a bug (see #13891): interactive elements inside `ui5-li-custom`
appear unreachable because plain Tab intentionally leaves the list.

- Extend the "Keyboard Handling" JSDoc block on `ui5-list` with a
  new "Edit Mode" subsection covering F2, F7, edit-mode Tab flow
  across items, and column-wise Arrow Up/Down navigation.
- Add a "Keyboard Handling" JSDoc section to `ui5-li-custom` that
  spells out how to reach its interactive slotted content and
  cross-references `ui5-list` for the full behavior.
- Add a "Keyboard Handling" section and a runnable sample
  (`KeyboardHandling`) to the docs website's List page, including
  a `selectionMode="Delete"` example that demonstrates the delete
  button being Tab-reachable in edit mode.

Follow-up of #12700 (F7 + Arrow Up/Down cross-item navigation)
and #13411 (edit mode via F2/F7 with Tab flow across items).

Fixes #13891.
kgogov added a commit that referenced this pull request Aug 13, 2026
…#13900)

* docs(ui5-list, ui5-li-custom): document edit-mode keyboard navigation

Document the SAP Fiori "Intentional Edit Pattern" keyboard
interactions (F2 / F7 / Tab / Arrow Up/Down) that were shipped in
two prior changes but were not reflected in the JSDoc or on the
docs website. The gap led users to report the intended behavior as
a bug (see #13891): interactive elements inside `ui5-li-custom`
appear unreachable because plain Tab intentionally leaves the list.

- Extend the "Keyboard Handling" JSDoc block on `ui5-list` with a
  new "Edit Mode" subsection covering F2, F7, edit-mode Tab flow
  across items, and column-wise Arrow Up/Down navigation.
- Add a "Keyboard Handling" JSDoc section to `ui5-li-custom` that
  spells out how to reach its interactive slotted content and
  cross-references `ui5-list` for the full behavior.
- Add a "Keyboard Handling" section and a runnable sample
  (`KeyboardHandling`) to the docs website's List page, including
  a `selectionMode="Delete"` example that demonstrates the delete
  button being Tab-reachable in edit mode.

Follow-up of #12700 (F7 + Arrow Up/Down cross-item navigation)
and #13411 (edit mode via F2/F7 with Tab flow across items).

Fixes #13891.

* docs(ui5-li-custom): split F2 and F7 keyboard bullets

F2 always focuses the first interactive element, while F7 restores the
last remembered position (falling back to first). The previous single
bullet incorrectly implied F2 also restored the remembered position.

Matches the wording already used in the ui5-list Keyboard Handling
section.

* docs(ui5-list): clarify F2 always focuses the first interactive element

The F2 bullet said only "Toggles edit mode on the focused item", which
did not state where focus lands. That left the distinction from F7 (last
remembered position, fallback to first) unclear. Spell out the contract
for F2 explicitly.

Follow-up to review feedback on #13900.

This branch was previously deployed

1 inactive deployment
preview — e9a48c5b Deployed Dec 9, 2025 by ui5-webcomponents-bot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants