From bc33aafaae1a877cfec90a175894d7437bfe9db3 Mon Sep 17 00:00:00 2001 From: George Mamadashvili Date: Thu, 15 Jul 2021 16:05:39 +0400 Subject: [PATCH] Suggestion List: Check if a node exists to scroll into view (#33419) Missing node source will cause an error in the scrollIntoView function and crash the editor. --- .../components/src/form-token-field/suggestions-list.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/components/src/form-token-field/suggestions-list.js b/packages/components/src/form-token-field/suggestions-list.js index 0f8b44c4068a0e..1ad0ace0a3b89e 100644 --- a/packages/components/src/form-token-field/suggestions-list.js +++ b/packages/components/src/form-token-field/suggestions-list.js @@ -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 ],