-
Notifications
You must be signed in to change notification settings - Fork 165
[terra-list]Fix for terra-menu console error #3935
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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(); | ||
} | ||
Comment on lines
+165
to
+167
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These changes should be tested There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes have tested by creating the tar file with this change on terra-menu . For reference please check the screen recording attached in PR description for pre and post implementation . There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, bad wording on my part. I trust that this was tested before submitting 🙂 What I meant was that we should write tests for these to test the condition and any potential edge cases. It can be a unit test or a wdio test. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @sdadn For this particular scenario not being able to create test :- These functionality can be hard because not being able to assert the focus invocation on null object ,which is making hard to write the test case to justify the changes made on List.jsx. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm I thought you could test the condition but that makes sense. If it's not possible, then the screen recording should be good enough. Thanks for trying! |
||
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: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are the errors?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Following is the error getting while navigating through arrow key (https://engineering.cerner.com/terra-framework/components/cerner-terra-framework-docs/menu/menu) :-
Uncaught TypeError: Cannot read properties of undefined (reading 'focus')
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can rephrase this to:
Fixed _property is undefined_ error while navigating with a keyboard.