From 33b917f506bfdb16dfcbca33db4c05d12aef4e52 Mon Sep 17 00:00:00 2001 From: kevin Date: Wed, 20 Dec 2023 11:00:24 -0700 Subject: [PATCH] fix(controller/search): addressing PR feedback to correct potential error --- .../snap-controller/src/Search/SearchController.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/snap-controller/src/Search/SearchController.ts b/packages/snap-controller/src/Search/SearchController.ts index 368e1bf3a..e027a63d7 100644 --- a/packages/snap-controller/src/Search/SearchController.ts +++ b/packages/snap-controller/src/Search/SearchController.ts @@ -137,10 +137,12 @@ export class SearchController extends AbstractController { // attempt to grab the element from storage if it is not provided if (!element?.selector) { const lastRequest = this.storage.get('lastStringyParams'); - const storableRequestParams = getStorableRequestParams(JSON.parse(lastRequest)); - const stringyParams = JSON.stringify(storableRequestParams); - const scrollMap: { [key: string]: ElementPositionObj } = this.storage.get('scrollMap') || {}; - element = scrollMap[stringyParams]; + if (lastRequest) { + const storableRequestParams = getStorableRequestParams(JSON.parse(lastRequest)); + const stringyParams = JSON.stringify(storableRequestParams); + const scrollMap: { [key: string]: ElementPositionObj } = this.storage.get('scrollMap') || {}; + element = scrollMap[stringyParams]; + } } const scrollToPosition = () => {