Fix dropdown interaction bug with DOM manipulation #229
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
Dropdown menus in Magento admin don't work, clicking them either redirects to Dashboard or does nothing.
This is related to #89, #121, and PR #112. The issue is that Playwright's accessibility tree updates before Magento's event handlers finish binding. When we click based on the tree saying an element is ready, the handlers aren't actually ready yet, so Magento's error handler kicks in and redirects.
Playwright also has a known popup menu rendering issue (microsoft/playwright#27142) that won't be fixed.
Solution
Check the element's role before clicking and handle dropdowns specially:
<option>elements: Use JavaScript to set.selectedand dispatch a change event directly, bypassing the accessibility tree.Changes
Added TreeNode infrastructure to track accessibility tree relationships, then updated the CLICK handler to detect and handle dropdown elements.
Code:
Testing
Tested in my modified environment, it fixes the dropdown issues. Can't guarantee it works in vanilla upstream though, would appreciate if you could test on the official setup, especially Magento dropdowns
References