diff --git a/packages/terra-list/CHANGELOG.md b/packages/terra-list/CHANGELOG.md index 9da6fc86bb6..7cafbe3100c 100644 --- a/packages/terra-list/CHANGELOG.md +++ b/packages/terra-list/CHANGELOG.md @@ -2,6 +2,9 @@ ## Unreleased +* Fixed + * Fixed _property is undefined_ error while navigating with a keyboard. + ## 4.65.0 - (October 16, 2023) * Changed diff --git a/packages/terra-list/src/List.jsx b/packages/terra-list/src/List.jsx index 2821101d3e6..d833a0c71e8 100644 --- a/packages/terra-list/src/List.jsx +++ b/packages/terra-list/src/List.jsx @@ -162,13 +162,17 @@ const List = ({ case KeyCode.KEY_UP: { event.preventDefault(); const previousIndex = currentIndex > 0 ? currentIndex - 1 : lastIndex; - listItems[previousIndex].focus(); + if (listItems[previousIndex]) { + listItems[previousIndex].focus(); + } break; } case KeyCode.KEY_DOWN: { event.preventDefault(); const nextIndex = currentIndex < lastIndex ? currentIndex + 1 : 0; - listItems[nextIndex].focus(); + if (listItems[nextIndex]) { + listItems[nextIndex].focus(); + } break; } default: