Skip to content

Commit

Permalink
fix: filters selection on mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
kreafox committed Mar 25, 2024
1 parent 0a60a99 commit 04ee9fe
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 16 deletions.
2 changes: 1 addition & 1 deletion searchlib/components/Facets/SidebarFacetsList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ export default function SidebarFacetsList(props) {
{facets.map((facetInfo, i) => (
<FacetResolver
key={i}
{...searchContext}
{...facetInfo}
{...searchContext}
wrapper="AccordionFacetWrapper"
/>
))}
Expand Down
17 changes: 4 additions & 13 deletions searchlib/components/Facets/Wrappers/DropdownFacetWrapper.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { connect } from 'react-redux';
import { useSelector } from 'react-redux';
import {
useAppConfig,
useProxiedSearchContext,
Expand All @@ -9,7 +9,7 @@ import {
SearchContext,
} from '@eeacms/search/lib/hocs';
import { Facet as SUIFacet } from '@eeacms/search/components';
import { Dimmer, Modal, Button, Loader } from 'semantic-ui-react';
import { Dimmer, Modal, Button } from 'semantic-ui-react';
import { atomFamily } from 'jotai/utils';
import { useAtom, atom } from 'jotai';
import cx from 'classnames';
Expand All @@ -32,8 +32,8 @@ const DropdownFacetWrapper = (props) => {
sortedOptions,
filterType,
isLoading,
token,
} = props;
const token = useSelector((state) => state.userSession.token);
const rawSearchContext = useSearchContext();
const {
searchContext: facetSearchContext,
Expand Down Expand Up @@ -99,20 +99,13 @@ const DropdownFacetWrapper = (props) => {
</Modal.Header>
<Modal.Content>
<SearchContext.Provider value={facetSearchContext}>
{isLoading && (
<Dimmer active>
<Loader active size="medium" />
</Dimmer>
)}

<SUIFacet
{...props}
active={isOpen}
filterType={localFilterType}
onChangeFilterType={setLocalFilterType}
/>
</SearchContext.Provider>

{!hideActiveFilters && (
<ActiveFilters
sortedOptions={sortedOptions}
Expand Down Expand Up @@ -212,6 +205,4 @@ const DropdownFacetWrapper = (props) => {
);
};

export default connect((state) => ({
token: state.userSession?.token,
}))(DropdownFacetWrapper);
export default DropdownFacetWrapper;
4 changes: 2 additions & 2 deletions searchlib/components/SearchApp/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,14 @@ export function removeFilter(name, value, type) {
let updatedFilters = [...(filters || [])];

if (!value && type) {
if (!filter.missing) {
if (!filter?.missing) {
updatedFilters = filters.filter(
(filter) => !(filter.field === name && filter.type === type),
);
} else {
updatedFilters = [
...filters.filter((filter) => filter.field !== name),
{ ...filter.missing, field: name },
{ ...filter?.missing, field: name },
];
}
} else if (value) {
Expand Down

0 comments on commit 04ee9fe

Please sign in to comment.