-
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
1650 bug nav collapsed state #1665
1650 bug nav collapsed state #1665
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 👍 !
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.
👍
@@ -7,11 +7,20 @@ class SemiCollapsibleNavigationClass { | |||
this.responsiveNavSetting = LuigiConfig.getConfigValue( | |||
'settings.responsiveNavigation' | |||
); | |||
this.semiCollapsible = | |||
let currentCollapsedState = localStorage.getItem( |
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.
My suggestion:
let currentCollapsedState = JSON.parse(localStorage.getItem(
NavigationHelpers.COL_NAV_KEY
));
You will get string instead of a boolean value if we don't parse the return value for currentCollapsedState
.
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.
done
this.responsiveNavSetting === 'Fiori3'; | ||
|
||
//checking if here was a previous state in localStorage before the reload | ||
if (currentCollapsedState != false && getResponsiveNavSettings) { |
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 remove the else part, because after a reload the variable this.semiCollapsible
will be always undefined and this lead to problems if you resize from desktop to mobile.
Code could look like this:
//checking if here was a previous state in localStorage before the reload
if (currentCollapsedState !== null && getResponsiveNavSettings) {
this.isSemiCollapsed = this.getCollapsed();
}
this.semiCollapsible = getResponsiveNavSettings ? true : false;
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.
done, thanks for checking
@@ -10,16 +10,15 @@ class SemiCollapsibleNavigationClass { | |||
let currentCollapsedState = localStorage.getItem( | |||
NavigationHelpers.COL_NAV_KEY | |||
); | |||
let checkTheResponsiveNavSettings = | |||
let getResponsiveNavSettings = |
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 seems using const
is more suitable. There is no updated afterward.
I would suggest name it with is-
prefix. e.g. const isResponsiveNavSemiCollapsibleOrFiori3
something like this. It is easier to understand at first sight.
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.
done
…h/luigi into 1650-bug-nav-collapsed-state
@@ -7,19 +7,23 @@ class SemiCollapsibleNavigationClass { | |||
this.responsiveNavSetting = LuigiConfig.getConfigValue( | |||
'settings.responsiveNavigation' | |||
); | |||
let currentCollapsedState = localStorage.getItem( | |||
NavigationHelpers.COL_NAV_KEY | |||
let currentCollapsedState = JSON.parse( |
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 should be const
as well.
Is this a boolean
? If so, could you please change to is
prefix naming?
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 is a string, Hannes mentioned it above, when suggested the changes
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 should be a boolean after JSON.parse
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.
right, mixed it up and now renamed to isCurrentStateCollapsed
this.responsiveNavSetting === 'semiCollapsible' || | ||
this.responsiveNavSetting === 'Fiori3'; | ||
|
||
//checking if here was a previous state in localStorage before the reload | ||
if (currentCollapsedState != false && getResponsiveNavSettings) { | ||
if ( | ||
currentCollapsedState != false && |
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.
Besides the naming, Please change to !==
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.
done
this.semiCollapsible = isResponsiveNavSemiCollapsibleOrFiori3 | ||
? true | ||
: false; |
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.semiCollapsible = isResponsiveNavSemiCollapsibleOrFiori3 | |
? true | |
: false; | |
this.semiCollapsible = isResponsiveNavSemiCollapsibleOrFiori3; |
Also, since semiCollapsible
is same as isResponsiveNavSemiCollapsibleOrFiori3
. Please check do we need this separate semiCollapsible
variable?
this.semiCollapsible && |
semiCollapsible: this.semiCollapsible |
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.
thanks for double-checking, We need it for the mobile collapsed state as well, so that on mobile the left side nav always set to 'true' even after the reload. And setting this.semiCollapsible = isResponsiveNavSemiCollapsibleOrFiori3;
doesn't give a chance to make it false
.
So I'd rather leave it as it is. What do you think?
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.
Good Job!
Fixes #1650
Extends the Core API UX part with a new function that allows collapsing the left side nav.
Docu and tests are attached