DEV Community

Sherotree
Sherotree

Posted on Fully Autonomous

Make the agent use the existing Dropdown Menu primitive, not a homemade absolutely-positioned list

The PR needs an overflow menu on a row or a header action. The agent adds a button, a useState open flag, and an absolutely positioned list of divs or links. Click-outside is a window listener. Escape is missing, or it closes and drops focus. The repo already has a DropdownMenu primitive with a trigger, a portal, arrow-key movement, typeahead, and focus return. Nearby card and table actions already use it.

I've started treating a homemade action list as an incomplete menu, not as a lighter dropdown. Toggling a panel is the easy part. A consistent trigger, keyboard movement, and a focus path back to the button are why the primitive is there.

Why the homemade menu shows up

A tutorial "custom dropdown" is a button plus a positioned list. The model can write that without finding components/DropdownMenu. Your primitive may wrap Radix or a design-system Menu, or it may be named ActionMenu or OverflowMenu, which is easy to miss if the prompt only says "add a ⋮ menu."

You also skip disabled items, separators, destructive item tone, and the rule about not using a menu when the job is a selectable combobox or a navigation landmark.

A simple Dropdown Menu policy

  • New overflow or action menus use the existing Dropdown Menu primitive
  • Do not build a button plus an absolutely positioned list in a feature file
  • Keep keyboard movement, Escape, and focus return on the primitive
  • A new item tone or placement is a primitive change, with a story

If the user is choosing one value from a list, that is a Select or Combobox, not a menu of checkable rows. If the list is primary navigation, that is a nav, not a dropdown of links styled as menu items.

What to put in the prompt

Use the existing Dropdown Menu primitive for this overflow or action menu.
Do not build a useState list with absolute positioning in this file.
Keep the trigger, keyboard movement, Escape, and focus return on the primitive.
If the control is a value picker or primary navigation, use the existing Select, Combobox, or nav instead.
Enter fullscreen mode Exit fullscreen mode

Paste one existing Dropdown Menu usage. In review, search the diff for a position: absolute action list, a window mousedown click-outside handler, and a div with onClick used as a menu item.

Reject / send back

Reject

  • A feature-level overflow menu that reimplements the Dropdown Menu primitive
  • A list that only works with a pointer and ignores Arrow keys and Escape
  • Focus left inside a closed portal, or not returned to the trigger
  • A second menu library added for one overflow button

Accept

  • An action menu that uses the existing Dropdown Menu primitive
  • A primitive PR that adds a documented item tone or placement and a story
  • A value picker or nav that stays on the existing Select, Combobox, or navigation component

Top comments (0)