Skip to content
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

Merged
merged 23 commits into from
Oct 28, 2020

Conversation

UlianaMunich
Copy link
Contributor

Fixes #1650

Extends the Core API UX part with a new function that allows collapsing the left side nav.

Docu and tests are attached

docs/luigi-core-api.md Outdated Show resolved Hide resolved
@ndricimrr ndricimrr self-assigned this Oct 20, 2020
Copy link
Contributor

@JohannesDoberer JohannesDoberer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍 !

Copy link
Contributor

@ndricimrr ndricimrr left a 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(
Copy link
Contributor

@JohannesDoberer JohannesDoberer Oct 26, 2020

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.

Copy link
Contributor Author

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) {
Copy link
Contributor

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;

Copy link
Contributor Author

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 =
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -7,19 +7,23 @@ class SemiCollapsibleNavigationClass {
this.responsiveNavSetting = LuigiConfig.getConfigValue(
'settings.responsiveNavigation'
);
let currentCollapsedState = localStorage.getItem(
NavigationHelpers.COL_NAV_KEY
let currentCollapsedState = JSON.parse(
Copy link
Contributor

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?

Copy link
Contributor Author

@UlianaMunich UlianaMunich Oct 28, 2020

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

Copy link
Contributor

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

Copy link
Contributor Author

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 &&
Copy link
Contributor

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 !==

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment on lines +24 to +26
this.semiCollapsible = isResponsiveNavSemiCollapsibleOrFiori3
? true
: false;
Copy link
Contributor

@stanleychh stanleychh Oct 27, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
this.semiCollapsible = isResponsiveNavSemiCollapsibleOrFiori3
? true
: false;
this.semiCollapsible = isResponsiveNavSemiCollapsibleOrFiori3;

Also, since semiCollapsible is same as isResponsiveNavSemiCollapsibleOrFiori3. Please check do we need this separate semiCollapsible variable?

and
semiCollapsible: this.semiCollapsible

Copy link
Contributor Author

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?

@stanleychh stanleychh self-assigned this Oct 28, 2020
Copy link
Contributor

@JohannesDoberer JohannesDoberer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good Job!

@UlianaMunich UlianaMunich merged commit 77c4e08 into SAP:master Oct 28, 2020
@UlianaMunich UlianaMunich deleted the 1650-bug-nav-collapsed-state branch October 28, 2020 14:24
@ndricimrr ndricimrr mentioned this pull request Oct 28, 2020
JohannesDoberer added a commit to JohannesDoberer/luigi that referenced this pull request Nov 2, 2020
* master:
  Update fiddle to 5.0.0 (SAP#1679)
  Docu fix (SAP#1681)
  Update contribution guidelines  (SAP#1655)
  Luigi 1.5 release notes (SAP#1678)
  Release 1.5.0 (SAP#1677)
  App Loading Indicator bug in docu (SAP#1661)
  Bug nav collapsed state (SAP#1665)
  IE11 domain check (SAP#1671)
stanleychh pushed a commit to stanleychh/luigi that referenced this pull request Dec 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

persisting collapsed state does not work anymore
4 participants