-
Notifications
You must be signed in to change notification settings - Fork 175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MWPW-146129 App Launcher overlaps the menu in Unav in the devices #2123
Changes from 10 commits
920c33c
beaf630
18e5aae
bcf845d
f1ac544
65c597f
91ad1b9
1915b2a
9414bfc
b8e6bd7
19d2886
925972c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -280,6 +280,10 @@ class Gnav { | |
if (this.useUniversalNav) { | ||
delete this.blocks.profile; | ||
this.blocks.universalNav = toFragment`<div class="feds-utilities"></div>`; | ||
this.blocks.universalNav.addEventListener('click', () => { | ||
const isExpanded = this.isToggleExpanded(); | ||
if (isExpanded) this.toggleMenuMobile(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This could be just one line, since |
||
}, true); | ||
} | ||
}; | ||
|
||
|
@@ -615,6 +619,18 @@ class Gnav { | |
}); | ||
}; | ||
|
||
isToggleExpanded = () => this.elements.mobileToggle?.getAttribute('aria-expanded') === 'true'; | ||
|
||
toggleMenuMobile = () => { | ||
const toggle = this.elements.mobileToggle; | ||
const isExpanded = this.isToggleExpanded(); | ||
toggle?.setAttribute('aria-expanded', !isExpanded); | ||
this.elements.navWrapper?.classList?.toggle('feds-nav-wrapper--expanded', !isExpanded); | ||
closeAllDropdowns(); | ||
setCurtainState(!isExpanded); | ||
toggle?.setAttribute('daa-ll', `hamburgermenu|${isExpanded ? 'open' : 'close'}`); | ||
}; | ||
|
||
decorateToggle = () => { | ||
if (!this.mainNavItemCount) return ''; | ||
|
||
|
@@ -638,12 +654,8 @@ class Gnav { | |
}; | ||
|
||
const onToggleClick = async () => { | ||
const isExpanded = toggle.getAttribute('aria-expanded') === 'true'; | ||
toggle.setAttribute('aria-expanded', !isExpanded); | ||
this.elements.navWrapper.classList.toggle('feds-nav-wrapper--expanded', !isExpanded); | ||
closeAllDropdowns(); | ||
setCurtainState(!isExpanded); | ||
toggle.setAttribute('daa-ll', `hamburgermenu|${isExpanded ? 'open' : 'close'}`); | ||
this.toggleMenuMobile(); | ||
const isExpanded = this.isToggleExpanded(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're just using the value of this variable once, you could simply use the function call on L666, where it's used. |
||
|
||
if (this.blocks?.search?.instance) { | ||
this.blocks.search.instance.clearSearchForm(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems not to work in adobe.com due to the following line (line 289 in utilities.js) in
closeAllDropDowns()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you have a test link? Why does the element have the
fedsPreventautoclose
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO emulating a click on the open element is not the right path. You should investigate why
fedsPreventautoclose
exists to begin with (might be related to the keyboard navigation using arrow keys, escape, etc.) and otherwise look into adapting thecloseAllDropdowns()
methodThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have a test link. The test links don't load the unav because the request for the JS file
403
s. Since it's a one liner, I tested it by adding a breakpoint in the Gnav Constructor and adding in the line manually (you need to do cmd + s for it to work).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAICT it is, as you pointed out, related somewhat to the keyboard navigation files. It's difficult to say just from reading the code, but it seems that it makes somewhat of a distinction between specifically a dropdown and the menu as it opens in mobile and tablet viewports.
IMO
closeAllDropdowns
isn't what we're looking for here. What we're looking for specifically is inside thedecorateToggle
method:The most expedient way to call this function without a fairly significant refactor is by clicking on the element it's attached to. Furthermore it ties the behavior we want to the behavior of the actual html elements the end user interacts with, and not to the abstract way it is done in the code, which is liable to churn. In other words clicking on the toggle element decouples the implementation of the behavior (close the menu when we click on
feds-utilities
) from the implementation of how exactly clicking on the toggle hides/shows the menu.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that we should generally avoid emulating click events, but in this scenario, it might be a reasonable approach. The
closeAllDropdowns
function is checking for open elements and whether they have the datasetfedsPreventautoclose
before closing. However, in this particular case, we need to overlook that and ensure that all menus close when someone clicks on the navigation.Another way would be for us to check open elements again, remove their dataset
fedsPreventautoclose
, and then call closeAllDropdowns, but in my opinion, that's not the right path to take. Therefore, using the click event seems fair in this scenario.