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

made the main page static and enabled scrolling in the filters component #5932

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion frontend/src/components/header/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export const Header = () => {
) : null;

return (
<header className="w-100 bb b--grey-light">
<header id="top-header" className="w-100 bb b--grey-light">
<UpdateDialog />
{checkUserEmail()}
{showOrgBar && (
Expand Down
1 change: 1 addition & 0 deletions frontend/src/components/projects/filterSelectFields.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ export const TagFilterPickerAutocomplete = ({

return (
<Select
menuPosition={'fixed'}
isLoading={tagOptions.isLoading}
onChange={handleTagChange}
classNamePrefix="react-select"
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/projects/projectNav.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export const ProjectNav = (props) => {
// onSelectedItemChange={(changes) => console.log(changes)}
return (
/* mb1 mb2-ns (removed for map, but now small gap for more-filters) */
<header className="bt bb b--tan w-100 ">
<header id="explore-nav" className="bt bb b--tan w-100 ">
<div className="mt2 mb1 ph3 dib lh-copy w-100 cf">
<div className="w-80-l w-90-m w-100 fl dib">
<div className="dib">
Expand Down
37 changes: 34 additions & 3 deletions frontend/src/views/project.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { Suspense, useEffect } from 'react';
import React, { Suspense, useEffect, useState } from 'react';
import { useSelector } from 'react-redux';
import ReactPlaceholder from 'react-placeholder';
import { Outlet, useLocation, useNavigate, useParams } from 'react-router-dom';
Expand Down Expand Up @@ -151,15 +151,46 @@ export const ProjectsPageIndex = (props) => {
export const MoreFilters = () => {
const navigate = useNavigate();
const [fullProjectsQuery] = useExploreProjectsQueryParams();
const [componentHeight, setComponentHeight] = useState(`${window.innerHeight}px`);

useEffect(() => {
document.body.style.overflow = 'hidden';
return () => {
document.body.style.overflow = 'auto';
};
}, []);

useEffect(() => {
const contentHeight =
document.getElementById('explore-nav').offsetHeight +
document.getElementById('top-header').offsetHeight;

const handleResize = () => {
setComponentHeight(window.innerHeight - contentHeight);
};

handleResize();

window.addEventListener('resize', handleResize);

return () => {
window.removeEventListener('resize', handleResize);
};
}, []);

const currentUrl = `/explore${
stringify(fullProjectsQuery) ? ['?', stringify(fullProjectsQuery)].join('') : ''
}`;

return (
<>
<div className="absolute left-0 z-4 mt1 w-40-l w-100 h-100 bg-white h4 ph1 ph5-l">
<MoreFiltersForm currentUrl={currentUrl} />
<div
className="absolute left-0 z-4 mt1 w-40-l w-100 bg-white h4 ph1 ph5-l"
style={{ height: `${componentHeight}px` }}
>
<div className="scrollable-container h-100 overflow-x-hidden overflow-y-auto">
<MoreFiltersForm currentUrl={currentUrl} />
</div>
</div>
<div
onClick={() => navigate(currentUrl)}
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/views/tests/project.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ describe('UserProjectsPage Component', () => {
});

test('More Filters should close the more filters container when clicked outside the container', async () => {
jest.spyOn(document, 'getElementById').mockReturnValue({ offsetHeight: 100 });

const { user, router } = createComponentWithMemoryRouter(
<QueryParamProvider adapter={ReactRouter6Adapter}>
<ReduxIntlProviders>
Expand Down