Skip to content
This repository has been archived by the owner on Oct 27, 2022. It is now read-only.

Commit

Permalink
fix: remove separator from first option in list (#872)
Browse files Browse the repository at this point in the history
  • Loading branch information
olav authored Apr 8, 2022
1 parent 363c071 commit 224349d
Showing 1 changed file with 17 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
semVerOperators,
dateOperators,
numOperators,
inOperators,
} from 'constants/operators';
import React, { useState, ChangeEvent } from 'react';
import { formatOperatorDescription } from 'component/common/ConstraintAccordion/ConstraintOperator/formatOperatorDescription';
Expand Down Expand Up @@ -61,7 +62,8 @@ export const ConstraintOperatorSelect = ({
key={operator}
value={operator}
className={classNames(
needSeparatorAbove(operator) && styles.separator
needSeparatorAbove(options, operator) &&
styles.separator
)}
>
<div className={styles.optionContainer}>
Expand All @@ -77,15 +79,20 @@ export const ConstraintOperatorSelect = ({
);
};

const needSeparatorAbove = (operator: Operator): boolean => {
const groups = [
stringOperators,
numOperators,
dateOperators,
semVerOperators,
];
const needSeparatorAbove = (options: Operator[], option: Operator): boolean => {
if (option === options[0]) {
return false;
}

return groups.some(group => {
return group[0] === operator;
return operatorGroups.some(group => {
return group[0] === option;
});
};

const operatorGroups = [
inOperators,
stringOperators,
numOperators,
dateOperators,
semVerOperators,
];

0 comments on commit 224349d

Please sign in to comment.