Skip to content

Commit

Permalink
Suggestion List: Check if a node exists to scroll into view (#33419)
Browse files Browse the repository at this point in the history
Missing node source will cause an error in the scrollIntoView function and crash the editor.
  • Loading branch information
Mamaduka authored and youknowriad committed Jul 15, 2021
1 parent c609c9a commit bc33aaf
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/components/src/form-token-field/suggestions-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ class SuggestionsList extends Component {
componentDidUpdate() {
// only have to worry about scrolling selected suggestion into view
// when already expanded
if ( this.props.selectedIndex > -1 && this.props.scrollIntoView ) {
if (
this.props.selectedIndex > -1 &&
this.props.scrollIntoView &&
this.list.children[ this.props.selectedIndex ]
) {
this.scrollingIntoView = true;
scrollIntoView(
this.list.children[ this.props.selectedIndex ],
Expand Down

0 comments on commit bc33aaf

Please sign in to comment.