You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add allowExceedingMax prop to LinearProgressBar for displaying values over 100%
Implement visual width capping at 100% to prevent UI overflow
Update aria-valuemax dynamically when value exceeds max
Add comprehensive tests and Storybook story for new feature
Diagram Walkthrough
flowchart LR
A["allowExceedingMax prop"] --> B["calculatePercentage helper"]
B --> C["valuePercentage calculation"]
C --> D["visualWidthPercentage capped at 100%"]
C --> E["ariaValueMax adjusted for accessibility"]
D --> F["Bar component width"]
E --> F
A --> G["Tests and Storybook story"]
Loading
File Walkthrough
Relevant files
Enhancement
LinearProgressBarHelpers.ts
Add allowExceeding parameter to percentage calculationΒ Β Β
Validate that setting aria-valuemax to a computed percentage (potentially > 100 and possibly fractional) is the intended accessibility behavior for this component, and that consumers/screen readers interpret aria-valuenow/aria-valuemax consistently when values exceed the traditional 0β100 range.
constariaValueMax=useMemo(()=>{// When allowExceedingMax is true and value exceeds max,// set aria-valuemax to the actual value percentage to maintain consistencyif(allowExceedingMax&&valuePercentage>100){returnMath.max(valuePercentage,100);}return100;},[allowExceedingMax,valuePercentage]);if(!value)returnnull;return(<divrole="progressbar"aria-label={barLabelName}aria-valuenow={valuePercentage}aria-valuemin={0}aria-valuemax={ariaValueMax}className={classNames}style={{width: `${visualWidthPercentage}%`,
...(color&&{backgroundColor: color})
calculatePercentage can yield Infinity/NaN when max equals min (division by zero). Consider guarding against this to avoid propagating invalid widths/ARIA values, especially now that values may exceed 100%.
The new tests rely on checking progressBarElement.style.width after rerenders; ensure the assertion matches how width is applied (inline style vs computed style) across the test environment, and consider also asserting aria-valuemax behavior when allowExceedingMax is enabled.
describe("exceeding max value",()=>{it("should cap percentage at 100% by default when value exceeds max",()=>{const{ rerender }=component;act(()=>{component=rerender(<LinearProgressBarvalue={120}max={100}id="test"indicateProgress={true}/>);});expect(screen.getByText("100%")).toBeTruthy();expect(screen.queryByText("120%")).toBeNull();});it("should show actual percentage when allowExceedingMax is true",()=>{const{ rerender }=component;act(()=>{component=rerender(<LinearProgressBarvalue={120}max={100}id="test"indicateProgress={true}allowExceedingMax={true}/>);});expect(screen.getByText("120%")).toBeTruthy();expect(screen.queryByText("100%")).toBeNull();});it("should handle secondary value exceeding max when allowExceedingMax is true",()=>{const{ rerender }=component;act(()=>{component=rerender(<LinearProgressBarvalue={150}valueSecondary={180}max={100}id="test"indicateProgress={true}allowExceedingMax={true}/>);});expect(screen.getByText("150%")).toBeTruthy();expect(screen.queryAllByRole("progressbar").length).toBe(2);});it("should cap visual bar width at 100% even when allowExceedingMax is true",()=>{const{ rerender }=component;act(()=>{component=rerender(<LinearProgressBarvalue={120}max={100}id="test"allowExceedingMax={true}/>);});constprogressBarElement=screen.getByRole("progressbar");expect(progressBarElement.style.width).toBe("100%");});});
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
User description
https://monday.monday.com/boards/3532714909/pulses/11338817756
PR Type
Enhancement
Description
Add
allowExceedingMaxprop to LinearProgressBar for displaying values over 100%Implement visual width capping at 100% to prevent UI overflow
Update aria-valuemax dynamically when value exceeds max
Add comprehensive tests and Storybook story for new feature
Diagram Walkthrough
File Walkthrough
LinearProgressBarHelpers.ts
Add allowExceeding parameter to percentage calculationΒ Β Βpackages/core/src/components/ProgressBars/LinearProgressBar/LinearProgressBarHelpers.ts
allowExceedingparameter tocalculatePercentagefunctionallowExceedingflagBar.tsx
Implement visual capping and aria accessibility updatesΒ Βpackages/core/src/components/ProgressBars/LinearProgressBar/Bar/Bar.tsx
allowExceedingMaxprop to BarProps interfacevisualWidthPercentagememo to cap bar width at 100%ariaValueMaxmemo to dynamically set aria-valuemax based onactual percentage
allowExceedingMaxtocalculatePercentagefunctionLinearProgressBar.tsx
Thread allowExceedingMax prop through component hierarchypackages/core/src/components/ProgressBars/LinearProgressBar/LinearProgressBar.tsx
allowExceedingMaxprop to LinearProgressBarProps interfaceallowExceedingMaxto all Bar component instances (primary,secondary, and multi-bars)
allowExceedingMaxin useMemo hooksLinearProgressBar.test.jsx
Add comprehensive tests for exceeding max featureΒ Β Β Β Β Β Β Βpackages/core/src/components/ProgressBars/LinearProgressBar/tests/LinearProgressBar.test.jsx
allowExceedingMaxis trueallowExceedingMaxallowExceedingMaxLinearProgressBar.stories.tsx
Add Storybook story for exceeding max featureΒ Β Β Β Β Β Β Β Β Β Β Βpackages/docs/src/pages/components/ProgressBars/LinearProgressBar.stories.tsx