Skip to content

Commit

Permalink
fix: focusFacetIndex check
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkh committed Dec 18, 2024
1 parent 07361be commit 3eb3979
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/vis/bar/components/FocusFacetSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type { ICommonVisProps } from '../../interfaces';
import { IBarConfig } from '../interfaces';

export function FocusFacetSelector({ config, setConfig, facets }: Pick<ICommonVisProps<IBarConfig>, 'config' | 'setConfig'> & { facets: string[] }) {
const isFacetFocused = React.useMemo(() => config?.focusFacetIndex !== null && config?.focusFacetIndex !== undefined, [config?.focusFacetIndex]);
const isFacetFocused: boolean = React.useMemo(() => config?.focusFacetIndex !== null && config?.focusFacetIndex !== undefined, [config?.focusFacetIndex]);

if (!config?.facets && facets.length === 0) {
return null;
Expand All @@ -19,7 +19,7 @@ export function FocusFacetSelector({ config, setConfig, facets }: Pick<ICommonVi
key={`focusFacetSelect_${config.focusFacetIndex ?? 0}`}
placeholder="Select a focus facet"
data={facets}
value={isFacetFocused ? facets[config?.focusFacetIndex as number] : ''}
value={isFacetFocused ? facets[config.focusFacetIndex ?? 0] : ''}
onChange={(value) => {
setConfig?.({ ...config, focusFacetIndex: typeof value === 'string' ? facets.indexOf(value) : value });
}}
Expand Down

0 comments on commit 3eb3979

Please sign in to comment.