Skip to content

Commit

Permalink
Merge pull request #2573 from rsun19/fixWhitespaceHeaderIssue
Browse files Browse the repository at this point in the history
[RHCLOUD-27099] Console landing page has bug where swiping left would reveal whitespace on mobile
  • Loading branch information
epwinchell authored Jul 18, 2023
2 parents 7219255 + f3673cc commit 35e6281
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/components/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const Header = ({ breadcrumbsProps }: { breadcrumbsProps?: Breadcrumbspro
const isITLessEnv = ITLess();
const { pathname } = useLocation();
const noBreadcrumb = !['/', '/allservices', '/favoritedservices'].includes(pathname);
const lg = useWindowWidth();
const { lg } = useWindowWidth();

return (
<Fragment>
Expand Down
4 changes: 3 additions & 1 deletion src/components/Header/Tools.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import LibtJWTContext from '../LibJWTContext';
import { ReduxState } from '../../redux/store';
import BellIcon from '@patternfly/react-icons/dist/esm/icons/bell-icon';
import { toggleNotificationsDrawer } from '../../redux/actions';
import useWindowWidth from '../../hooks/useWindowWidth';

const isITLessEnv = ITLess();

Expand Down Expand Up @@ -82,6 +83,7 @@ const Tools = () => {
isRhosakEntitled: false,
isDemoAcc: false,
});
const { xs } = useWindowWidth();
const user = useSelector(({ chrome: { user } }: ReduxState) => user!);
const unreadNotifications = useSelector(({ chrome: { notifications } }: ReduxState) => notifications?.data?.filter((isRead) => isRead) || []);
const isDrawerExpanded = useSelector(({ chrome: { notifications } }: ReduxState) => notifications?.isExpanded);
Expand Down Expand Up @@ -238,7 +240,7 @@ const Tools = () => {
},
})}
>
<BetaSwitcher />
{!xs && <BetaSwitcher />}
</ToolbarItem>
{isNotificationsEnabled && (
<ToolbarItem>
Expand Down
4 changes: 3 additions & 1 deletion src/hooks/useWindowWidth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@ import { useEffect, useState } from 'react';

const useWindowWidth = () => {
const [lg, setLg] = useState(window.innerWidth >= 1450);
const [xs, setXs] = useState(window.innerWidth < 420);

useEffect(() => {
const handleResize = () => {
setLg(window.innerWidth >= 1450);
setXs(window.innerWidth < 420);
};
window.addEventListener('resize', handleResize);
() => window.removeEventListener('resize', handleResize);
}, []);

return lg;
return { xs, lg };
};

export default useWindowWidth;

0 comments on commit 35e6281

Please sign in to comment.