[4.4] Fix event target in menu.js #44019
Merged
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.
Summary of Changes
The core menu.js dynamically adds
aria-hidden=true
attributes toul
tags on menu level 2:However, on focus and hover, these attributes aren't always set to "false" (which would be correct as the previously invisible dropdown now is possible) as the JS has a bug. It uses the
target
attribute of the event, which is not the element that the eventhandler was bound to (=the parent<li>
) but the element that triggered the event, i.e. a nested a or span tag.It should use currentTarget.
See msdn:
https://developer.mozilla.org/en-US/docs/Web/API/Event/currentTarget
Testing Instructions
Create a test site with a multi-level menu that uses the "default" menu layout. Make sure that the menu.js is loaded and the aria-hidden attribute is appended. Now hover over the element.
Actual result BEFORE applying this Pull Request
aria-hidden isn't updated reliably.
Expected result AFTER applying this Pull Request
aria-hidden is updated reliably.
Link to documentations
Please select:
Documentation link for docs.joomla.org:
[x ] No documentation changes for docs.joomla.org needed
Pull Request link for manual.joomla.org:
[ x] No documentation changes for manual.joomla.org needed