Skip to content

Commit ae1965e

Browse files
fix(UsageFilter): fix bar flashes (#457)
1 parent 05b4619 commit ae1965e

File tree

2 files changed

+18
-17
lines changed

2 files changed

+18
-17
lines changed

src/containers/Storage/UsageFilter/UsageFilter.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
&-meta {
1515
position: relative;
16+
z-index: 0;
1617

1718
padding: 0 5px;
1819

src/containers/Storage/UsageFilter/UsageFilter.tsx

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import cn from 'bem-cn-lite';
33

44
import {Select, SelectOption} from '@gravity-ui/uikit';
55

6-
import EntityStatus from "../../../components/EntityStatus/EntityStatus";
6+
import EntityStatus from '../../../components/EntityStatus/EntityStatus';
77

88
import {getUsageSeverityForEntityStatus} from '../utils';
99

@@ -27,14 +27,7 @@ interface UsageFilterProps {
2727
const b = cn('usage-filter');
2828

2929
export const UsageFilter = (props: UsageFilterProps) => {
30-
const {
31-
className,
32-
value = [],
33-
groups = [],
34-
onChange,
35-
debounce = 200,
36-
disabled,
37-
} = props;
30+
const {className, value = [], groups = [], onChange, debounce = 200, disabled} = props;
3831

3932
const [filterValue, setFilterValue] = useState(value);
4033
const timer = useRef<number>();
@@ -50,11 +43,15 @@ export const UsageFilter = (props: UsageFilterProps) => {
5043
});
5144
}, [value]);
5245

53-
const options = useMemo(() => groups.map(({threshold, count}) => ({
54-
value: String(threshold),
55-
text: `${threshold}%`,
56-
data: {count}
57-
})), [groups]);
46+
const options = useMemo(
47+
() =>
48+
groups.map(({threshold, count}) => ({
49+
value: String(threshold),
50+
text: `${threshold}%`,
51+
data: {count},
52+
})),
53+
[groups],
54+
);
5855

5956
const handleUpdate = (newValue: string[]) => {
6057
setFilterValue(newValue);
@@ -67,17 +64,20 @@ export const UsageFilter = (props: UsageFilterProps) => {
6764

6865
const maxWidth = Math.max(...groups.map(({count}) => count));
6966

70-
const renderOption = ({value, data, text}: SelectOption) => (
67+
const renderOption = ({value: optionValue, data, text}: SelectOption) => (
7168
<div className={b('option')}>
7269
<EntityStatus
7370
className={b('option-title')}
74-
status={getUsageSeverityForEntityStatus(Number(value))}
71+
status={getUsageSeverityForEntityStatus(Number(optionValue))}
7572
name={text}
7673
size="xs"
7774
/>
7875
<div className={b('option-meta')}>
7976
{i18n('groups_count', {count: data.count})}
80-
<div className={b('option-bar')} style={{width: `${data.count / maxWidth * 100}%`}} />
77+
<div
78+
className={b('option-bar')}
79+
style={{width: `${(data.count / maxWidth) * 100}%`}}
80+
/>
8181
</div>
8282
</div>
8383
);

0 commit comments

Comments
 (0)