Skip to content

Conversation

@ritorhymes
Copy link

Summary

Adds swipe gesture controls for the mobile/tablet Table of Contents (ToC) drawer:

  • Swipe right to open the ToC drawer
  • Swipe left to close the ToC drawer

Gestures are only enabled when the nav toggle button is visible (i.e., on mobile/tablet viewports). To prevent accidental toggles, swipe handling is ignored when the gesture begins inside horizontally scrollable elements (e.g., code blocks).

Dependency

This PR is stacked on PR #242, which establishes the foundational open/close state behavior and keeps aria-expanded correctly synced. This PR builds on that foundation so swipe interactions update the same state and accessibility attributes.

Rationale

Given the extreme length of the page, the ToC drawer on mobile is essential to navigate with and can be expected to be used frequently so its accessibility and ergonomics matter. Swiping to open/close a side drawer is a common and familiar behavior and may be preferred for some users, and it can be more comfortable than needing to stretch your thumb to the top of the screen each time to open it.

Testing

You can test the functionality out on this live demo: https://zaproxy-api.ritovision.com/

The sensitivity should behave such that vertical scrolling shouldn’t trigger the toggle, nor should tiny left/right movements that are more indicative of incidental finger shifting rather than an intentional swipe.

I tested this on an Android phone (≈450px width) on Chrome, Firefox, and Edge; the behaviors were consistent, smooth, and stable across each.

  • Vertical scrolling does not trigger the drawer.
  • Small incidental horizontal finger movement does not trigger the drawer.
  • Intentional horizontal swipes reliably open/close the drawer.
  • Swipes starting inside horizontally scrollable areas (e.g., code blocks) do not toggle the drawer.

Convert TOC wrapper to a semantic landmark with aria-label and a stable id for aria-controls.

Keep nav button aria-expanded synced on open/close.

Set aria-current='location' on the active ToC link and clear it from the previous active link.

Close the ToC via Escape key when the nav toggle is visible.

Signed-off-by: Rito Rhymes <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant