@@ -196,7 +196,7 @@ export const ChartLegend = ({
196196 title = { defaultTitle }
197197 items = { defaultItems }
198198 ariaLabel = { "Default legend" }
199- scrolableContainerRef = { containerRef }
199+ scrollableContainerRef = { containerRef }
200200 { ...legendGroupProps }
201201 />
202202 { oppositeItems . length > 0 && (
@@ -207,7 +207,7 @@ export const ChartLegend = ({
207207 title = { oppositeTitle }
208208 items = { oppositeItems }
209209 ariaLabel = { "Opposite legend" }
210- scrolableContainerRef = { containerRef }
210+ scrollableContainerRef = { containerRef }
211211 { ...legendGroupProps }
212212 />
213213 </ >
@@ -251,7 +251,7 @@ interface LegendItemsProps {
251251 highlightControl : DebouncedCall ;
252252 items : readonly LegendItem [ ] ;
253253 tooltipRef : React . RefObject < HTMLElement > ;
254- scrolableContainerRef ?: React . RefObject < HTMLElement > ;
254+ scrollableContainerRef ?: React . RefObject < HTMLElement > ;
255255 position : "bottom" | "bottom-default" | "bottom-opposite" | "side" ;
256256 elementsByIdRef : React . MutableRefObject < Record < string , HTMLElement > > ;
257257 onItemHighlightExit : ( ) => void ;
@@ -273,7 +273,7 @@ const LegendGroup = ({
273273 someHighlighted,
274274 elementsByIdRef,
275275 highlightControl,
276- scrolableContainerRef ,
276+ scrollableContainerRef ,
277277 onToggleItem,
278278 onSelectItem,
279279 onShowTooltip,
@@ -303,7 +303,7 @@ const LegendGroup = ({
303303 if ( isMouseInContainer . current ) {
304304 return ;
305305 }
306- const container = scrolableContainerRef ?. current ?? containerRef . current ;
306+ const container = scrollableContainerRef ?. current ?? containerRef . current ;
307307 const element = elementsByIdRef . current ?. [ highlightedId ] ;
308308 if ( ! container || ! element ) {
309309 return ;
@@ -425,7 +425,7 @@ const LegendGroup = ({
425425 if ( containerRef . current ) {
426426 const highlightedIndex = items . findIndex ( ( item ) => item . highlighted ) ;
427427 const buttons : HTMLButtonElement [ ] = Array . from ( containerRef . current . querySelectorAll ( `.${ styles . item } ` ) ) ;
428- return buttons [ highlightedIndex ] ?? null ;
428+ return buttons [ highlightedIndex ] ?? buttons [ 0 ] ;
429429 }
430430 return null ;
431431 }
0 commit comments