Skip to content

Commit

Permalink
fix(filter-picker): 修复列表型切换操作符的问题 (#1968)
Browse files Browse the repository at this point in the history
Co-authored-by: maxin <[email protected]>
  • Loading branch information
nnmax and maxin authored Apr 12, 2022
1 parent ffd7fa8 commit 282aeb1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,19 @@ function FilterAttrOverlay(props: FilterAttrOverlayProps) {
[]
);

/**
* 切换数据类型的时候需要重置 attrValue
*/
const previousValueType = usePrevious(valueType);
useEffect(() => {
if (valueType !== previousValueType && isEmpty(values)) {
if (previousValueType !== undefined && valueType !== previousValueType && isEmpty(values)) {
setAttrValue([]);
}
setOperationValue(getOperation(valueType, op, values));
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [previousValueType, valueType, op, getOperation]);
}, [previousValueType, valueType]);
useEffect(() => {
setOperationValue(getOperation(valueType, op, values));
}, [getOperation, op, valueType, values]);

const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
setChecked(e.target.checked);
Expand Down
4 changes: 2 additions & 2 deletions src/legacy/filter-picker/locales/en-US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@ export default {
afterTheNext: (text: Key) => `After the next ${text} day(s)`,
withinThePast: (text: Key) => `Within the past ${text} day(s)`,
withinTheNext: (text: Key) => `Within the next ${text} day(s)`,
empty: 'Empty',
notEmpty: 'Not empty',
empty: 'No value',
notEmpty: 'Has value',
};
4 changes: 2 additions & 2 deletions src/legacy/filter-picker/locales/zh-CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@ export default {
afterTheNext: (text: Key) => `未来 ${text} 天后`,
withinThePast: (text: Key) => `过去 ${text} 天之内`,
withinTheNext: (text: Key) => `未来 ${text} 天之内`,
empty: '为空',
notEmpty: '不为空',
empty: '无值',
notEmpty: '有值',
};

1 comment on commit 282aeb1

@vercel
Copy link

@vercel vercel bot commented on 282aeb1 Apr 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

gio-design – ./

gio-design.vercel.app
gio-design-git-master-growingio.vercel.app
gio-design-growingio.vercel.app

Please sign in to comment.