Browse Source

Revert "fix(Badge): update cached isDotRef when isHidden (#30090)" (#30277)

This reverts commit d87901e9a5.
pull/30276/head
afc163 4 years ago
committed by GitHub
parent
commit
eec7eca5b3
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 13
      components/badge/__tests__/index.test.js
  2. 6
      components/badge/index.tsx

13
components/badge/__tests__/index.test.js

@ -155,19 +155,6 @@ describe('Badge', () => {
expect(wrapper.find('.ant-badge')).toHaveLength(2); 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', () => { describe('Ribbon', () => {

6
components/badge/index.tsx

@ -94,8 +94,6 @@ const Badge: CompoundedComponent = ({
const isDotRef = useRef(showAsDot); const isDotRef = useRef(showAsDot);
if (!isHidden) { if (!isHidden) {
isDotRef.current = showAsDot; isDotRef.current = showAsDot;
} else {
isDotRef.current = false;
} }
// =============================== Styles =============================== // =============================== Styles ===============================
@ -188,8 +186,8 @@ const Badge: CompoundedComponent = ({
const scrollNumberCls = classNames({ const scrollNumberCls = classNames({
[`${prefixCls}-dot`]: isDot, [`${prefixCls}-dot`]: isDot,
[`${prefixCls}-count`]: !isDot && !isHidden, [`${prefixCls}-count`]: !isDot,
[`${prefixCls}-count-sm`]: !isDot && !isHidden && size === 'small', [`${prefixCls}-count-sm`]: size === 'small',
[`${prefixCls}-multiple-words`]: [`${prefixCls}-multiple-words`]:
!isDot && displayCount && displayCount.toString().length > 1, !isDot && displayCount && displayCount.toString().length > 1,
[`${prefixCls}-status-${status}`]: !!status, [`${prefixCls}-status-${status}`]: !!status,

Loading…
Cancel
Save