Skip to content

Commit 40502dd

Browse files
committed
fix bug in MultiSelectValueFacet
1 parent bbe09a9 commit 40502dd

File tree

5 files changed

+29
-59
lines changed

5 files changed

+29
-59
lines changed

packages/frontend/src/components/facets/MultiSelectValueFacet.tsx

Lines changed: 9 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useState, useMemo } from 'react';
1+
import React, { useState, useMemo, useCallback } from 'react';
22
import { EnumFacetResponse, FacetCardProps, FacetDataHooks } from './types';
33
import { MultiSelect, Tooltip } from '@mantine/core';
44
import {
@@ -108,6 +108,7 @@ const MultiSelectValueFacet: React.FC<ExactValueProps> = ({
108108

109109
useDeepCompareEffect(() => {
110110
if (!facetValue || isFacetEmpty(facetValue)) {
111+
console.log('filters', '[]');
111112
setSelectedValues([]);
112113
} else if (instanceOfIncludesExcludes(facetValue)) {
113114
const filters = facetValue.operands.map((x: number | string) =>
@@ -117,42 +118,13 @@ const MultiSelectValueFacet: React.FC<ExactValueProps> = ({
117118
}
118119
}, [facetValue]);
119120

120-
// useDeepCompareEffect(() => {
121-
// const setValues = (values: string[]) => {
122-
// if (values.length > 0) {
123-
// if (facetValue && instanceOfIncludesExcludes(facetValue)) {
124-
// // updating facet value
125-
// updateFacetFilters(field, {
126-
// ...facetValue,
127-
// operands: values,
128-
// });
129-
// }
130-
// if (facetValue === undefined) {
131-
// // TODO: Assuming Includes by default but this might change to Include|Excludes
132-
// updateFacetFilters(field, {
133-
// operator: 'in',
134-
// field: field,
135-
// operands: values,
136-
// });
137-
// }
138-
// }
139-
// // no values remove the filter
140-
// else {
141-
// clearFilters(field);
142-
// }
143-
// };
144-
//
145-
// setValues(selectedValues);
146-
// }, [selectedValues]);
147-
148-
useDeepCompareEffect(() => {
149-
const setValues = (values: string[]) => {
121+
// update the filter which will also update selected values
122+
const updateFilters = useCallback(
123+
(values: string[]) => {
150124
updateFacetEnum(field, values, updateFacetFilters, clearFilters);
151-
};
152-
153-
console.log('selectedValues: ', selectedValues);
154-
setValues(selectedValues);
155-
}, [selectedValues]);
125+
},
126+
[clearFilters, field, updateFacetFilters],
127+
);
156128

157129
return (
158130
<div
@@ -184,7 +156,7 @@ const MultiSelectValueFacet: React.FC<ExactValueProps> = ({
184156
comboboxProps={{ shadow: 'md' }}
185157
aria-label="enter value to add filter"
186158
value={selectedValues}
187-
onChange={setSelectedValues}
159+
onChange={updateFilters}
188160
searchable
189161
data={dataValues}
190162
limit={10}

packages/frontend/src/features/CohortBuilder/CohortPanel.tsx

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -235,17 +235,12 @@ export const CohortPanel = ({
235235
<div className="flex flex-col mt-3 relative px-4 bg-base-light w-full">
236236
<LoadingOverlay visible={isAggsQueryFetching} />
237237
<CohortManager index={index} />
238+
239+
{/* Flex container to ensure proper 25/75 split */}
238240
<div className="flex w-full">
239-
<div className="flex w-1/4">
240-
{filters?.tabs === undefined ? null : filters?.tabs.length > 1 ? (
241-
<DropdownPanel
242-
index={index}
243-
filters={filters}
244-
tabTitle={tabTitle}
245-
facetDefinitions={facetDefinitions}
246-
facetDataHooks={facetDataHooks}
247-
/>
248-
) : (
241+
{/* Left panel - 25% */}
242+
<div id="cohort-filters-content" className="flex-shrink-0 w-1/4 ">
243+
{filters?.tabs && (
249244
<DropdownPanel
250245
index={index}
251246
filters={filters}
@@ -255,7 +250,10 @@ export const CohortPanel = ({
255250
/>
256251
)}
257252
</div>
258-
<div className="flex flex-col w-full ml-4 ">
253+
254+
{/* Right content - 75% */}
255+
<div id="cohort-builder-content" className="flex flex-col w-3/4 pl-4">
256+
{/* Top row with DownloadsPanel and CountsValue */}
259257
<div className="flex justify-between mb-2 ml-2">
260258
<DownloadsPanel
261259
dropdowns={dropdowns ?? {}}
@@ -266,28 +264,29 @@ export const CohortPanel = ({
266264
fields={table?.fields ?? []}
267265
filter={cohortFilters}
268266
/>
269-
270267
<CountsValue
271268
label={guppyConfig?.nodeCountTitle || toDisplayName(index)}
272269
counts={counts}
273270
isSuccess={isCountSuccess}
274271
/>
275272
</div>
273+
274+
{/* Charts Section */}
276275
<Charts
277276
charts={summaryCharts}
278277
data={data ?? EmptyData}
279278
counts={counts}
280279
isSuccess={isSuccess}
281280
numCols={numCols}
282281
/>
283-
{table?.enabled ? (
282+
283+
{/* Table Section */}
284+
{table?.enabled && (
284285
<div className="mt-2 flex flex-col">
285286
<div className="grid">
286287
<ExplorerTable index={index} tableConfig={table} />
287288
</div>
288289
</div>
289-
) : (
290-
false
291290
)}
292291
</div>
293292
</div>

packages/frontend/src/features/CohortBuilder/FiltersPanel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export const FiltersPanel = ({
2525
undefined,
2626
false,
2727
facetDefinition.label,
28-
'w-full',
28+
undefined,
2929
);
3030
})}
3131
</div>

packages/frontend/src/features/CohortBuilder/Panels/DropdownPanel.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export const DropdownPanel = ({
4646
}, [] as FacetDefinition[]);
4747

4848
return (
49-
<Stack align="flex-start" className="mx-3 w-full">
49+
<Stack align="flex-start">
5050
<Group justify="space-between" className="w-full">
5151
<Text size="xl" fw={800}>
5252
Filters
@@ -58,7 +58,7 @@ export const DropdownPanel = ({
5858
{allFiltersCollapsed ? 'Expand All' : 'Collapse All'}
5959
</button>
6060
</Group>
61-
<Stack className="w-full bg-base-max py-4 px-2 h-full">
61+
<Stack className="bg-base-max py-4 px-2 h-full w-full">
6262
<Group gap="xs" justify="space-between">
6363
<div className="flex items-center space-x-1">
6464
<Icon

packages/sampleCommons/src/pages/_app.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ import {
1212
Fonts,
1313
createMantineTheme,
1414
SessionConfiguration,
15-
// registerCohortDiscoveryApp,
16-
registerCohortDistanceApp,
15+
registerExplorerDefaultCellRenderers,
1716
registerCohortBuilderDefaultPreviewRenderers,
1817
registerMetadataSchemaApp,
1918
} from '@gen3/frontend';
@@ -65,13 +64,13 @@ const Gen3App = ({
6564
// one time init
6665
// if (
6766
// process.env.NEXT_PUBLIC_FARO_COLLECTOR_URL &&
68-
// process.env.NEXT_PUBLIC_FARO_APP_ENVIRONMENT != "local" &&
67+
// process.env.NEXT_PBLIC_FARO_APP_ENVIRONMENT != "local" &&
6968
// !faroRef.current
7069
// ) {
7170
if (!faroRef.current) faroRef.current = initGrafanaFaro();
7271
// registerCohortDiscoveryApp();
73-
registerCohortDistanceApp();
7472
registerMetadataSchemaApp();
73+
registerExplorerDefaultCellRenderers();
7574
registerCohortBuilderDefaultPreviewRenderers();
7675
registerCohortTableCustomCellRenderers();
7776
registerCustomExplorerDetailsPanels();

0 commit comments

Comments
 (0)