Skip to content

Commit

Permalink
Merge branch 'fix/filter-order' into 'dev'
Browse files Browse the repository at this point in the history
fix(filter): order of filters

See merge request Frontend/synerise-design!2221
  • Loading branch information
Aram Farahi committed Dec 22, 2021
2 parents c2345db + c46c1a4 commit eb9fb27
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/components/filter/src/Filter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ const Filter: React.FC<FilterProps> = ({
addFilterComponent,
texts,
}) => {
const [activeExpressionId, setActiveExpressionId] = React.useState<string | null>(null);

const { formatMessage } = useIntl();
const text = React.useMemo(
() => ({
Expand Down Expand Up @@ -94,7 +96,13 @@ const Filter: React.FC<FilterProps> = ({
const Component = component[expression.type];
const LogicComponent = expression.logic && component[expression.logic.type];
return (
<S.ExpressionWrapper key={expression.id} data-dropLabel={text.dropMeHere} index={index}>
<S.ExpressionWrapper
key={expression.id}
data-dropLabel={text.dropMeHere}
index={index}
style={expression.id === activeExpressionId ? { zIndex: 10001 } : undefined}
onClick={(): void => setActiveExpressionId(expression.id)}
>
<Component {...expression.data} {...componentProps(expression)} />
{expression.logic && index + 1 < expressions.length && (
<S.LogicWrapper>
Expand All @@ -104,7 +112,7 @@ const Filter: React.FC<FilterProps> = ({
</S.ExpressionWrapper>
);
},
[componentProps, expressions.length, text]
[componentProps, expressions.length, activeExpressionId, text]
);

return (
Expand Down

0 comments on commit eb9fb27

Please sign in to comment.