Skip to content

Commit

Permalink
fix: when closing advanced filter, scroll simple controls into view
Browse files Browse the repository at this point in the history
Ref: #44
  • Loading branch information
stdavis committed Jul 22, 2022
1 parent b5d82e6 commit a436c68
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/components/Filter.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import FeatureFilter from '@arcgis/core/layers/support/FeatureFilter';
import PropTypes from 'prop-types';
import React from 'react';
import React, { useRef } from 'react';
import { ErrorBoundary } from 'react-error-boundary';
import { Alert, Nav, NavItem, NavLink, TabContent, TabPane } from 'reactstrap';
import { format } from 'sql-formatter';
Expand All @@ -20,7 +20,13 @@ ErrorFallback.propTypes = {

export default function Filter({ mapView, state, dispatch }) {
const [isAdvancedOpen, setIsAdvancedOpen] = React.useState(false);
const toggleAdvanced = () => setIsAdvancedOpen((current) => !current);
const headerRef = useRef();
const toggleAdvanced = () => {
if (isAdvancedOpen) {
headerRef.current.scrollIntoView();
}
setIsAdvancedOpen((current) => !current);
};

const layers = useMapLayers(mapView, config.filter.layerNames);

Expand Down Expand Up @@ -58,7 +64,7 @@ export default function Filter({ mapView, state, dispatch }) {
return (
<>
<ErrorBoundary FallbackComponent={ErrorFallback}>
<h5>Display RTP Projects by</h5>
<h5 ref={headerRef}>Display RTP Projects by</h5>
<div className="d-flex justify-content-between align-items-center position-relative">
<Nav tabs>
<NavItem>
Expand Down

0 comments on commit a436c68

Please sign in to comment.