Skip to content

fix: recognize role="listitem" as interactive element#203

Open
Lubrsy706 wants to merge 1 commit intoalibaba:mainfrom
Lubrsy706:fix/recognize-listitem-role-as-interactive
Open

fix: recognize role="listitem" as interactive element#203
Lubrsy706 wants to merge 1 commit intoalibaba:mainfrom
Lubrsy706:fix/recognize-listitem-role-as-interactive

Conversation

@Lubrsy706
Copy link
Contributor

Summary

Fixes #193

Elements with role="listitem" (used by Quasar Framework's q-item components and other UI libraries) were not recognized as individually interactive. Instead, only the parent menu/list container was highlighted as a single interactive element, making it impossible for the LLM to click individual list items.

Root Cause

role="listitem" was missing from two role sets:

  1. interactiveRoles in isInteractiveElement() — elements with this role were not detected as interactive (unless caught by cursor:pointer heuristic)
  2. INTERACTIVE_ROLES in isElementDistinctInteraction() — even if detected as interactive, these elements were not considered "distinct" from their parent, so they were skipped when the parent container was already highlighted

Fix

Add 'listitem' to both sets. This ensures:

  • isInteractiveElement() recognizes role="listitem" elements as interactive
  • isElementDistinctInteraction() treats them as independent interactions (not collapsed into parent)

Quasar Example

<div role="menu" class="q-menu">
  <div class="q-list" role="list">
    <div class="q-item q-item--clickable" role="listitem" tabindex="0">
      <div class="q-item__label">Registration</div>
    </div>
    <div class="q-item q-item--clickable" role="listitem" tabindex="0">
      <div class="q-item__label">Change of Registered</div>
    </div>
  </div>
</div>
  • Before: Only [0]<div role="menu"> was highlighted — individual items invisible to LLM
  • After: Each [0]<div role="listitem">Registration, [1]<div role="listitem">Change of Registered highlighted separately

Test Plan

  • npm run build passes
  • npm run lint passes
  • Manual test: Quasar dropdown with role="listitem" items are individually highlighted

🤖 Generated with Claude Code

Add `listitem` to both `interactiveRoles` and `INTERACTIVE_ROLES` sets
so that elements with `role="listitem"` (e.g. Quasar Framework's
q-item components) are detected as individually interactive and
highlighted separately, instead of being collapsed into their parent
menu container.

Closes alibaba#193

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@CLAassistant
Copy link

CLAassistant commented Mar 11, 2026

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] DOM识别错误

2 participants