From e33b2f2f56608ae2da907b791c2bc16a6a7d0c15 Mon Sep 17 00:00:00 2001
From: Manoj Vivek
Date: Wed, 22 Jul 2020 09:31:49 +0530
Subject: [PATCH] Address bar improvements
---
desktop-app/app/components/Addressinput/style.css | 3 +++
.../app/services/searchUrlSuggestions/index.js | 15 +++++++++++++--
2 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/desktop-app/app/components/Addressinput/style.css b/desktop-app/app/components/Addressinput/style.css
index 381a97c4..3e93a938 100644
--- a/desktop-app/app/components/Addressinput/style.css
+++ b/desktop-app/app/components/Addressinput/style.css
@@ -60,6 +60,7 @@
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
+ cursor: default;
}
.searchBarSuggestionsListUl {
@@ -70,8 +71,10 @@
.searchBarSuggestionsListItems:hover {
background: gray;
+ color: white;
}
.searchBarSuggestionsListItems.active {
background: gray;
+ color: white;
}
diff --git a/desktop-app/app/services/searchUrlSuggestions/index.js b/desktop-app/app/services/searchUrlSuggestions/index.js
index 39d246a0..7af155f0 100644
--- a/desktop-app/app/services/searchUrlSuggestions/index.js
+++ b/desktop-app/app/services/searchUrlSuggestions/index.js
@@ -37,9 +37,17 @@ export const searchUrlUtils = url => {
return [];
};
+const normalizeURL = url => {
+ if (url.indexOf('?') === -1 && !url.endsWith('/')) {
+ url = `${url}/`;
+ }
+ return url;
+};
+
export const updateExistingUrl = url => {
+ url = normalizeURL(url);
if (previousSearchResults?.length) {
- const updatedSearchResults = [...previousSearchResults];
+ let updatedSearchResults = [...previousSearchResults];
const index = updatedSearchResults.findIndex(
eachSearchResult => eachSearchResult.url === url
@@ -49,7 +57,10 @@ export const updateExistingUrl = url => {
updatedSearchResults[index].visitedCount =
1 + updatedSearchResults[index].visitedCount;
} else {
- updatedSearchResults.push({url, visitedCount: 1});
+ updatedSearchResults = [
+ {url, visitedCount: 1},
+ ...updatedSearchResults,
+ ].slice(0, 300);
}
addUrlToSearchResults(updatedSearchResults);