Skip to content

Commit

Permalink
[Progress] Set zero width when value is zero (#1204)
Browse files Browse the repository at this point in the history
  • Loading branch information
mj12albert authored Dec 21, 2024
1 parent 9b7ec75 commit 3167ec6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
19 changes: 18 additions & 1 deletion packages/react/src/progress/indicator/ProgressIndicator.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,28 @@ describe('<Progress.Indicator />', () => {
const indicator = getByTestId('indicator');

expect(indicator).toHaveComputedStyle({
left: '0px',
insetInlineStart: '0px',
width: '33%',
});
});

it('sets zero width when value is 0', async () => {
const { getByTestId } = await render(
<Progress.Root value={0}>
<Progress.Track>
<Progress.Indicator data-testid="indicator" />
</Progress.Track>
</Progress.Root>,
);

const indicator = getByTestId('indicator');

expect(indicator).toHaveComputedStyle({
insetInlineStart: '0px',
width: '0%',
});
});

it('indeterminate', async () => {
const { getByTestId } = await render(
<Progress.Root value={null}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function useProgressIndicator(
Number.isFinite(value) && value !== null ? valueToPercent(value, min, max) : null;

const getStyles = React.useCallback(() => {
if (!percentageValue) {
if (percentageValue == null) {
return {};
}

Expand Down

0 comments on commit 3167ec6

Please sign in to comment.