Skip to content

Commit

Permalink
Revert "fix(Badge): update cached isDotRef when isHidden (#30090)"
Browse files Browse the repository at this point in the history
This reverts commit d87901e.
  • Loading branch information
afc163 committed Apr 22, 2021
1 parent 2140e81 commit a86e043
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 17 deletions.
13 changes: 0 additions & 13 deletions components/badge/__tests__/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,19 +155,6 @@ describe('Badge', () => {

expect(wrapper.find('.ant-badge')).toHaveLength(2);
});

it('Badge should work when status changes', () => {
const wrapper = mount(
<Badge status="warning">
<button type="button">Click me</button>
</Badge>,
);
wrapper.setProps({ status: undefined });

expect(wrapper.find('.ant-badge-count')).toHaveLength(0);
expect(wrapper.find('.ant-badge-dot')).toHaveLength(0);
expect(wrapper.find('.ant-badge-count-sm')).toHaveLength(0);
});
});

describe('Ribbon', () => {
Expand Down
6 changes: 2 additions & 4 deletions components/badge/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,6 @@ const Badge: CompoundedComponent = ({
const isDotRef = useRef(showAsDot);
if (!isHidden) {
isDotRef.current = showAsDot;
} else {
isDotRef.current = false;
}

// =============================== Styles ===============================
Expand Down Expand Up @@ -188,8 +186,8 @@ const Badge: CompoundedComponent = ({

const scrollNumberCls = classNames({
[`${prefixCls}-dot`]: isDot,
[`${prefixCls}-count`]: !isDot && !isHidden,
[`${prefixCls}-count-sm`]: !isDot && !isHidden && size === 'small',
[`${prefixCls}-count`]: !isDot,
[`${prefixCls}-count-sm`]: size === 'small',
[`${prefixCls}-multiple-words`]:
!isDot && displayCount && displayCount.toString().length > 1,
[`${prefixCls}-status-${status}`]: !!status,
Expand Down

0 comments on commit a86e043

Please sign in to comment.