From 61ddfa336db65ebdd14c0206c101a779abd5b7c3 Mon Sep 17 00:00:00 2001 From: Viktor Baranov Date: Mon, 2 Aug 2021 15:14:40 +0300 Subject: [PATCH] Fix Cannot read property toLowerCase of undefined --- CHANGELOG.md | 1 + apps/block_scout_web/assets/js/lib/autocomplete.js | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d63454ee85..4b07feb627 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ### Features ### Fixes +- [#4472](https://github.com/blockscout/blockscout/pull/4472) - Search autocomplete: Fix Cannot read property toLowerCase of undefined - [#4456](https://github.com/blockscout/blockscout/pull/4456) - URL encoding for NFT media files URLs - [#4453](https://github.com/blockscout/blockscout/pull/4453) - Unescape characters for string output type in the contract response - [#4401](https://github.com/blockscout/blockscout/pull/4401) - Fix displaying of token holders with the same amount diff --git a/apps/block_scout_web/assets/js/lib/autocomplete.js b/apps/block_scout_web/assets/js/lib/autocomplete.js index 91abe306e2..89024bd5fb 100644 --- a/apps/block_scout_web/assets/js/lib/autocomplete.js +++ b/apps/block_scout_web/assets/js/lib/autocomplete.js @@ -43,9 +43,12 @@ const resultsListElement = (list, data) => { fetchTextAdData() } const searchEngine = (query, record) => { - if (record.name.toLowerCase().includes(query.toLowerCase()) || - record.symbol.toLowerCase().includes(query.toLowerCase()) || - record.contract_address_hash.toLowerCase().includes(query.toLowerCase())) { + if (record && ( + (record.name && record.name.toLowerCase().includes(query.toLowerCase())) || + (record.symbol && record.symbol.toLowerCase().includes(query.toLowerCase())) || + (record.contract_address_hash && record.contract_address_hash.toLowerCase().includes(query.toLowerCase())) + ) + ) { var searchResult = `${record.contract_address_hash}
` if (record.type === 'label') { searchResult += `
${record.name}`