-
Notifications
You must be signed in to change notification settings - Fork 987
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
Fixes #30412 - fix shifted react-container #7821
Fixes #30412 - fix shifted react-container #7821
Conversation
Issues: #30412 |
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 @LaViro 👍
We are getting the same features, it fixes a bug and it removes 140 lines of code. Sound like a good deal for me.
app/assets/stylesheets/base.scss
Outdated
patternfly-sass hides the vertical-nav on smaller screens, see: https://github.com/patternfly/patternfly-sass/blob/5e7cce3445d5b1af1e16500695b9f33edc6a4f6c/assets/javascripts/patternfly-functions.js#L260 | ||
the react-container needs to be shifted when it happens. | ||
*/ | ||
@media only screen and (max-width: 768px) { |
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.
Can we put it in webpack and import the pf3 variable for the max-width?
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, added those in my last commit
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.
Resolved
Look like it we still have it in the session storage, does patternfly manage that internally? |
@sharvit after doing a hard reset to the browser I don't see it in the session anymore:
@MariaAga If they use the same scss classnames, it even make the implementation easier because |
From the other side, I don't think pf4 has the implementation for collapsing the menu so we might want to keep the logic? |
@MariaAga is it correct? |
There is an option to open/close the menu in PF4,I use oncollapse to move the page content (forexample host table) to the right of the menu and not under it when it's open |
@LaViro the reason for the sessionStorage is to keep the state of the menu when you are refreshing the page or moving to a different page (if it's not using client-routing). |
I still think in this case we should use only css, based of the width of the screen, look how much code does it reduce.
interesting, I didn't see any usecase of do you have any other concerns? I didn't find any regression |
Generally I'm not sure it's a good idea to add PRs right now to the old PF3 layout with PF3 rules when we have a PR to replace it with PF4 |
Well currently there is a bug in all of this pages, |
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 @LaViro 👍
Looks like the pf3 component manages the session-storage for us, see:
https://github.com/patternfly/patternfly-react/blob/patternfly-3/packages/patternfly-react/src/components/VerticalNav/VerticalNav.js#L120
$pf-global--breakpoint--md: 768px !default; | ||
$pf-global--breakpoint--lg: 992px !default; | ||
$pf-global--breakpoint--xl: 1200px !default; | ||
$pf-global--breakpoint--2xl: 1450px !default; |
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.
nice thanks! I will change it.
while we are at it, is it possible to make those variables available all over the app without the import?
can we do the same for colors variables?
interesting, is that a good practice? |
0083cab
to
12c3bf7
Compare
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 think so, that way we can keep it in the same state when moving between pages |
To solve this I think it be easier to just change: foreman/webpack/assets/javascripts/react_app/components/Layout/LayoutSessionStorage.js Line 4 in 0c9ddcc
to
And then we don't have to add more PF3 to our code... |
12c3bf7
to
769b0d2
Compare
Thanks! I forgot we can do that :) :) thanks @MariaAga, added your session suggestion though the container was shifted 200px to the right on small screens when the vertical nav is hidden. ready for another review 👍 |
@media only screen and (max-width: $pf-global--breakpoint--md) { | ||
.react-container { | ||
margin-left: 0; | ||
} | ||
} |
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 is getting overridden by the previous rule:
&.collapsed-nav { margin-left: 75px; }
as #react-app-root is an ID so the rule is more specific
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, fixed the situation where screen was small and nav collapsed 👍
769b0d2
to
742d98a
Compare
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 @LaViro, tested on some foreman pages and also Katello Angular and React pages. works great!
Just one nit below
@@ -1,4 +1,4 @@ | |||
import { getValue } from '../../common/SessionStorage'; | |||
|
|||
export const getIsNavbarCollapsed = () => | |||
!!getValue(`["navCollapsed","pinnedPath"]`); | |||
!!getValue(`["navCollapsed","pinnedPath"]`)?.navCollapsed; |
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.
Optional chaining party! 🎉
Prefer adding parenthesis to avoid ambiguity (does the !!
apply to everything?)
!!getValue(`["navCollapsed","pinnedPath"]`)?.navCollapsed; | |
!!(getValue(`["navCollapsed","pinnedPath"]`)?.navCollapsed); |
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.
no need to add !!
operator
the navCollapsed
is already a boolean
btw, this line caused the regression with the vertical navigation
Thanks for the @media
extra feature :)
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.
no need to add !! operator
the navCollapsed is already a boolean
before the user clicks to collapse the menu, the values are initially set to null
by us
I guess that's why !!
was used,to make sure it's a boolean.
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.
works for me without the !!
null is still a false value in conditions
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.
ok lets do this.. since it's only being used to set a className it's indeed not important if it's null
or 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.
oh no.. removing it just failed 4 snapshots in travis
showing undefined
instead of false
.. I am reverting it so the snapshot will stay the same
@jeremylenz I tried to add those brackets you ask for, but the prettier linter is annoyed by that and ask to remove it :(
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.
If we can't ignore the lint rule I'd go for updating the snapshots. But either way this isn't a big enough deal to be a blocker, if it has to remain without parenthesis then I guess I'll live with it 🤷♂️
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 prefer a snapshot with the prop as false
instead of undefined
because it is not clear whether the prop wasn't passed at all, or was it pass as undefined
?
(in our case it was passed as undefined
)
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.
React and not React margin works correctly now 🎉
742d98a
to
e497c06
Compare
rebased as Refactor the Layout component got merged, |
e497c06
to
ec7832b
Compare
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.
Works for me, test failure unrelated.
Thanks @LaViro and @sharvit, @jeremylenz, @MariaAga and @amirfefer for reviews! 👍
This is something that I think css
@media
query would do the work for.patternfly hides the vertical-nav when the page gets smaller
I think our JS implementation is overkill to what the layout needs to do - to shift to the left when the vertical nav is hidden.
I don't think we need to use the
session
for it, and I didn't notice anyone using theON_COLLAPSE
/ON_EXPAND
actions.current react pages are shifted:
this is how it looks with this PR: