From 28cac6917f7a55f08fd4eaffa3f857a0997cb592 Mon Sep 17 00:00:00 2001 From: Joseph Frazer Date: Thu, 26 Sep 2019 13:24:39 -0400 Subject: [PATCH] [DEV-5872] Catch when an element is not present When a question has been removed, but exists in a bucket for an existing quote, it cannot find the element to hide and it ends up showing all (or mostly all) question elements. We are ignoring this case since the possible side effects of ignoring them are less severe than what happens now. Additionally, the way this works will be changing in the future. --- src/ui/group/StackedGroupUi.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/ui/group/StackedGroupUi.js b/src/ui/group/StackedGroupUi.js index 881f6c5..45af5e5 100644 --- a/src/ui/group/StackedGroupUi.js +++ b/src/ui/group/StackedGroupUi.js @@ -114,9 +114,22 @@ module.exports = Class( 'StackedGroupUi' ) if ( !this.hasVisibleField( index ) ) { - const header = this._$container.find( 'dl' )[ index ]; + // This possible effects of ignoring these errors has been + // deemed less severe than the current effects when it fails + // (i.e. showing all the questions). + // This will also eventually be changed to have the elements + // be hidden by default and show when appropriate. This will + // likely fix the current issue and reduce the chances of + // something like this happening. + try { + const header = this._$container.find( 'dl' )[ index ]; - header.classList.add( 'hidden' ); + header.classList.add( 'hidden' ); + } + catch( e ) + { + console.warn( e ); + } } },