mirror of
https://github.com/Unleash/unleash.git
synced 2025-07-26 13:48:33 +02:00
fix: remove separator from first option in list (#872)
This commit is contained in:
parent
49b8e7329e
commit
df60f2301f
@ -5,6 +5,7 @@ import {
|
|||||||
semVerOperators,
|
semVerOperators,
|
||||||
dateOperators,
|
dateOperators,
|
||||||
numOperators,
|
numOperators,
|
||||||
|
inOperators,
|
||||||
} from 'constants/operators';
|
} from 'constants/operators';
|
||||||
import React, { useState, ChangeEvent } from 'react';
|
import React, { useState, ChangeEvent } from 'react';
|
||||||
import { formatOperatorDescription } from 'component/common/ConstraintAccordion/ConstraintOperator/formatOperatorDescription';
|
import { formatOperatorDescription } from 'component/common/ConstraintAccordion/ConstraintOperator/formatOperatorDescription';
|
||||||
@ -61,7 +62,8 @@ export const ConstraintOperatorSelect = ({
|
|||||||
key={operator}
|
key={operator}
|
||||||
value={operator}
|
value={operator}
|
||||||
className={classNames(
|
className={classNames(
|
||||||
needSeparatorAbove(operator) && styles.separator
|
needSeparatorAbove(options, operator) &&
|
||||||
|
styles.separator
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<div className={styles.optionContainer}>
|
<div className={styles.optionContainer}>
|
||||||
@ -77,15 +79,20 @@ export const ConstraintOperatorSelect = ({
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const needSeparatorAbove = (operator: Operator): boolean => {
|
const needSeparatorAbove = (options: Operator[], option: Operator): boolean => {
|
||||||
const groups = [
|
if (option === options[0]) {
|
||||||
stringOperators,
|
return false;
|
||||||
numOperators,
|
}
|
||||||
dateOperators,
|
|
||||||
semVerOperators,
|
|
||||||
];
|
|
||||||
|
|
||||||
return groups.some(group => {
|
return operatorGroups.some(group => {
|
||||||
return group[0] === operator;
|
return group[0] === option;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const operatorGroups = [
|
||||||
|
inOperators,
|
||||||
|
stringOperators,
|
||||||
|
numOperators,
|
||||||
|
dateOperators,
|
||||||
|
semVerOperators,
|
||||||
|
];
|
||||||
|
Loading…
Reference in New Issue
Block a user