Bug: HSOverlay intercepts Enter key on nested anchor links, preventing navigation
Summary
When an anchor () inside an hs-overlay sidebar receives keyboard focus, pressing Enter opens the overlay instead of navigating to the link.
Steps to Reproduce
- Create a responsive sidebar using hs-overlay with lg:block.
- Add an anchor element inside the sidebar.
- Focus the anchor using Tab.
- Press Enter.
Root cause:
The accessibility observer registers the parent hs-overlay as the active component even when focus is on a descendant anchor.
On desktop, the sidebar is visible through lg:block, but Preline reports isOpened: false. Consequently, pressing Enter triggers the overlay's open() method instead of the anchor's native navigation.
Workaround:
Stop propagation of Enter key events originating from anchor elements inside the sidebar, without preventing their default behavior.
Demo Link
not available
Expected Behavior
The anchor should navigate to its href, preserving native keyboard accessibility.
Actual Behavior
Preline's HSAccessibilityObserver.handleGlobalKeydown() intercepts Enter, executes the overlay's onEnter handler, and calls event.preventDefault(), preventing navigation.
Screenshots
No response
Thank you for the clear explanation and for highlighting the keyboard accessibility impact!
This has been addressed in Preline 5.1.0. Pressing Enter on a link or button inside an Overlay should now activate the focused element, including links in responsive sidebars that remain visible on larger screens.
We’ll close this issue as resolved. If the behavior persists after updating, please feel free to share a small reproduction so we can investigate further. Thanks again!