Skip to content

[material-ui][Badge] When showZero={false} and value is 0 content is not updated #43081

Open
@wg-xb

Description

@wg-xb

Steps to reproduce

Link to live example: (required)
Demo in Stackblitz : https://stackblitz.com/edit/react-qkjzbj?file=Demo.tsx
Steps:

  1. Inspect .MuiBadge-badge elements in dev tools
  2. Click "Set to 0" and observe

Current behavior

  • For Badge with showZero={false} content of .MuiBadge-badge element will not be updated (will still be 8, depite of element being not visible)
  • For Badge with showZero={true} content of .MuiBadge-badge element will be updated

Expected behavior

I believe this is wrong and content should updated to current value, even if element is not visible

Context

I am using Badge component and while testing if it visually hidden and has zero value when value is changed from anything other than 0 tests are failing because element is hidden but old value is present in the DOM.

Your environment

npx @mui/envinfo
  Don't forget to mention which browser you used.
  Output from `npx @mui/envinfo` goes here.

Search keywords: MuiBadge

Metadata

Metadata

Assignees

Labels

bug 🐛Something doesn't workcomponent: badgeThis is the name of the generic UI component, not the React module!package: material-uiSpecific to @mui/material

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions