From dea3b29946a5ccf7a2c12d012b7b8abf7352107a Mon Sep 17 00:00:00 2001 From: Coltin Kifer Date: Tue, 7 May 2024 22:44:14 -0700 Subject: [PATCH] fix: guard against accidental undefined access in Brush (#4504) ## Description Fix brush bug experienced in current release, guard against it in 3.x too ## Related Issue This is interesting... not sure why people use Brush like this? Asked for a reason in the comment https://github.com/recharts/recharts/issues/2093#issuecomment-2098161840 ## Motivation and Context bug prevention ## How Has This Been Tested? it hasn't really, but it doesn't hurt anything ## Screenshots (if appropriate): ## Types of changes - [X] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) ## Checklist: - [ ] My change requires a change to the documentation. - [ ] I have updated the documentation accordingly. - [ ] I have added tests to cover my changes. - [ ] I have added a storybook story or extended an existing story to show my changes Co-authored-by: Coltin Kifer --- src/cartesian/Brush.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cartesian/Brush.tsx b/src/cartesian/Brush.tsx index 2f563b7afd..9bf625df40 100644 --- a/src/cartesian/Brush.tsx +++ b/src/cartesian/Brush.tsx @@ -134,7 +134,7 @@ function TravellerLayer({ height, }; - const ariaLabelBrush = ariaLabel || `Min value: ${data[startIndex].name}, Max value: ${data[endIndex].name}`; + const ariaLabelBrush = ariaLabel || `Min value: ${data[startIndex]?.name}, Max value: ${data[endIndex]?.name}`; return (