-
Notifications
You must be signed in to change notification settings - Fork 174
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
Fix dropdowns behavior on click events #301
Fix dropdowns behavior on click events #301
Conversation
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.
LGTM
It still does not work perfectly - in chrome when you click on a bottom part of the entry (somewhere in the last quarter of the highlighted area, below the text) it does not get activated - in the context chooser as well as the Logout button. In firefox the context chooser works fine but the Logout button has the same problem as in chrome. |
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.
It works well. I have a couple of refactoring suggenstions, please see my comments.
There are some refactorings I would definitely apply to the logic related to dropdowns, but this is out of scope for this task, we might do it in a different task. This is what I would change:
- Context switcher should just read and not write the
dropdownStates
object and instead fire an event to topNav component, since it is not responsibility of context switcher to do that and we are duplicating some methods, more preciselycloseAllDropdowns
,toggleDropdownState
anddropDownStatesNegated
. - Have dropdown states as booleans and not as strings
- Remove
dropDownStatesNegated
method DropdownStates
properties should be cased consistently with the rest of the code base (thisWay
and notTHAT_WAY
)
this.set({ | ||
dropDownStates | ||
}); | ||
}, | ||
closeDropdown(name) { | ||
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.
I would refactor this method, also in ContextSwitcher
component, to the following:
closeAllDropdowns() {
const dropDownStates = this.get().dropDownStates || {};
Object.keys(dropDownStates).forEach(k => { dropDownStates[k] = 'false' });
this.set({dropDownStates});
}
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.
dropDownStates
is an empty object at the beginning. Adding the foreach loop without checking if the array of keys is not empty, would cause errors.
core/src/navigation/TopNav.html
Outdated
|
||
{#if !authorizationEnabled || isLoggedIn} | ||
<ContextSwitcher {dropDownStates} bind:dropDownStates /> |
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.
Not something you introduced, but {dropDownStates}
is not needed here.
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.
As it is working as required and you are working next week and I will be on vacation, I am approving it now. Please still consider my refactoring suggestions before merging.
* Fix dropdowns actions on click event
Description
Changes proposed in this pull request:
Related issue(s)