Skip to content
easeweb
Search topics

Right-click, long-press and swipe actions with no button

A list's actions sit in a menu that only a right-click or a long press opens, or behind a swipe, and no row has a button that reaches them.

WCAG 2.2
SC 2.1.1ASC 2.5.1A· new in 2.1
Required by
Section 508 · EN 301 549 (EU)
Broken list.addEventListener('contextmenu', openMenu)
The accessibility problem illustrated: Motor:How do I download it?
01

The problem

People who use a keyboard, a switch, voice control or a screen reader, and anyone who can't make the gesture or doesn't guess it, can't reach a row's actions

02

Try it

Delete “Signed contract.pdf”, then put the mouse aside and try again with Tab

  • Broken 1: right-click the file, or press and hold it, to open its menu. With Tab alone, can you reach Download, Make a copy and Delete?

  • Broken 2: swipe the file to the left to show its Delete button. With Tab alone, can you reach it?

  • Apply a fix. Try Tab again. The panel shows what a screen reader announces: do you hear which file each action is for?

Broken Can you fix this?

Shared documents

  • Invoice 0412.pdf
  • Signed contract.pdf
  • Brand guide.pdf

Help with shared files

A recreated demo. The broken version is intentionally inaccessible.

03

The fix

Keep the gesture, and put its actions on a button per row

Before

Actions only in a right-click or long-press menu

<ul class="files">  <li data-file="invoice">Invoice 0412.pdf</li>  <li data-file="contract">Signed contract.pdf</li>  <li data-file="brand">Brand guide.pdf</li></ul><div class="file-menu" hidden>  <button type="button" data-action="download">Download</button>  <button type="button" data-action="copy">Make a copy</button>  <button type="button" data-action="delete">Delete</button></div>
What is wrong3 points
  • Keyboard, switch and voice control users can't open the menu. It opens only from a right-click or a held touch.
  • A keyboard user can't even reach a place where Shift + F10 would fire. The rows can't take focus.
  • People who don't know the gesture never find the actions. Nothing on screen says a menu exists.
After

An Actions menu button that opens the same actions

<li data-file="invoice">  <span id="file-invoice">Invoice 0412.pdf</span>  <button type="button" popovertarget="menu-invoice" aria-haspopup="menu" aria-describedby="file-invoice">    Actions  </button>  <div id="menu-invoice" popover role="menu" aria-labelledby="file-invoice" class="file-menu">    <button type="button" role="menuitem" tabindex="-1" data-action="download">Download</button>    <button type="button" role="menuitem" tabindex="-1" data-action="copy">Make a copy</button>    <button type="button" role="menuitem" tabindex="-1" data-action="delete">Delete</button>  </div></li>
How it is fixed6 steps
  1. Give every row an Actions button with popovertarget. It opens the menu with a click, a tap, Enter or Space, and voice control users can say "Click Actions".
  2. Make the menu a popover. It opens above the page, Escape or a click outside closes it, and focus returns to the Actions button.
  3. Add aria-haspopup="menu", so a screen reader says the button opens a menu, and name the menu from the file, so it is read as "Invoice 0412.pdf, menu" when focus enters it.
  4. Make it work like the browser's own context menu, which is what people reach for first: focus moves to the first action when it opens, Up and Down Arrow move through the actions, Home and End go to the first and last, and Tab closes the menu and moves on.
  5. Run an action on Enter or a click, and close the menu.
  6. Leave the right-click and long-press menu as it was, so nobody loses the shortcut.

This fixes both Befores and passes 2.1.1 and 2.5.1. Position the menu under its button with CSS anchor positioning or a few lines of script; a popover is centred on the screen until you do.

04

Verify the fix

5 checks.

Test with: Keyboard, Mouse, Touch, Screen reader, Speech input

0 of 5 checked

Record the OS, browser and assistive-technology versions, the build, the date, and the actual result of each step. Repeat after the list component or its menu library changes.

How screen readers handle aria-describedby

Limits

This is a starting pattern, not a guarantee for every application. Rows moved by dragging, long-press selection of several items, and gestures on maps and images such as pinch to zoom have their own needs, and are not covered here; for those, see pinch, drag and tilt gestures with no button. Actions that a row or card shows only while the pointer rests on it are covered in card actions that only appear on hover. A key that has to be held down, or pressed again in time, is covered in hold-to-confirm buttons and other timed key presses. An Actions button whose menu opens with focus left behind, or whose items the arrow keys never reach, is covered in action menus that open silently, out of keyboard reach. Menu libraries differ in how they handle focus, Escape and placement: test the complete journey with your target assistive technology.

This is a recreated teaching example, not a finding about a named client. The code is a starting pattern: test it in your own product. No completed assistive-technology test is claimed here.

EaseWeb service

Fixed it? Keep it from coming back.

I turn guides like this one into rules your coding agents follow and checks your CI runs. Then I retest by hand with a keyboard and screen readers, periodically.

See the service