From 28863a312733b0cdc14182593e708a2bbfbe13de Mon Sep 17 00:00:00 2001
From: Lautaro Petaccio <1120791+LautaroPetaccio@users.noreply.github.com>
Date: Wed, 10 Jul 2024 09:31:42 -0300
Subject: [PATCH] fix: Names search showing other assets (#2266)
---
webapp/src/components/AssetBrowse/AssetBrowse.tsx | 3 ++-
webapp/src/components/AssetBrowse/AssetBrowse.types.ts | 6 +++++-
webapp/src/components/AssetTopbar/AssetTopbar.tsx | 5 +++--
webapp/src/components/AssetTopbar/AssetTopbar.types.ts | 1 +
webapp/src/components/NamesPage/NamesPage.tsx | 8 +++++++-
webapp/src/modules/routing/selectors.spec.ts | 6 ++++++
webapp/src/modules/routing/selectors.ts | 4 ++++
7 files changed, 28 insertions(+), 5 deletions(-)
diff --git a/webapp/src/components/AssetBrowse/AssetBrowse.tsx b/webapp/src/components/AssetBrowse/AssetBrowse.tsx
index 2e63c9671..86dd1086a 100644
--- a/webapp/src/components/AssetBrowse/AssetBrowse.tsx
+++ b/webapp/src/components/AssetBrowse/AssetBrowse.tsx
@@ -44,6 +44,7 @@ const AssetBrowse = (props: Props) => {
onlyOnSale,
onlySmart,
viewInState,
+ disableSearchDropdown,
onlyOnRent
} = props
@@ -186,7 +187,7 @@ const AssetBrowse = (props: Props) => {
case DecentralandSection.ENS:
right = (
<>
-
+
>
)
diff --git a/webapp/src/components/AssetBrowse/AssetBrowse.types.ts b/webapp/src/components/AssetBrowse/AssetBrowse.types.ts
index c50dbb808..cd4585dd2 100644
--- a/webapp/src/components/AssetBrowse/AssetBrowse.types.ts
+++ b/webapp/src/components/AssetBrowse/AssetBrowse.types.ts
@@ -22,6 +22,7 @@ export type Props = {
onBrowse: typeof browse
onlyOnSale?: boolean
onlySmart?: boolean
+ disableSearchDropdown?: boolean
onlyOnRent?: boolean
}
@@ -31,4 +32,7 @@ export type MapStateProps = Pick<
>
export type MapDispatchProps = Pick
export type MapDispatch = Dispatch
-export type OwnProps = Pick
+export type OwnProps = Pick<
+ Props,
+ 'vendor' | 'address' | 'isFullscreen' | 'isMap' | 'view' | 'sections' | 'section' | 'contracts' | 'disableSearchDropdown'
+>
diff --git a/webapp/src/components/AssetTopbar/AssetTopbar.tsx b/webapp/src/components/AssetTopbar/AssetTopbar.tsx
index fac5fe1ea..69f17ccbc 100644
--- a/webapp/src/components/AssetTopbar/AssetTopbar.tsx
+++ b/webapp/src/components/AssetTopbar/AssetTopbar.tsx
@@ -30,6 +30,7 @@ export const AssetTopbar = ({
onBrowse,
onClearFilters,
onOpenFiltersModal,
+ disableSearchDropdown,
sortByOptions
}: Props): JSX.Element => {
const isMobile = useTabletAndBelowMediaQuery()
@@ -41,7 +42,7 @@ export const AssetTopbar = ({
const handleInputChange = useCallback(
(text: string) => {
// if the user is typing, open the dropdown
- if (!shouldRenderSearchDropdown && text) {
+ if (!shouldRenderSearchDropdown && text && !disableSearchDropdown) {
setShouldRenderSearchDropdown(true)
}
// if the user clears the input, reset the search
@@ -50,7 +51,7 @@ export const AssetTopbar = ({
search: ''
}) // triggers search with no search term
}
- if (shouldRenderSearchDropdown) {
+ if (shouldRenderSearchDropdown && !disableSearchDropdown) {
setSearchValueForDropdown(text)
} else if (text && text !== search) {
// common search, when the dropdown is not opened and the input is different than the current search term
diff --git a/webapp/src/components/AssetTopbar/AssetTopbar.types.ts b/webapp/src/components/AssetTopbar/AssetTopbar.types.ts
index f05945d1a..85bbbc3f1 100644
--- a/webapp/src/components/AssetTopbar/AssetTopbar.types.ts
+++ b/webapp/src/components/AssetTopbar/AssetTopbar.types.ts
@@ -18,6 +18,7 @@ export type Props = {
section: Section
hasFiltersEnabled: boolean
isLoading: boolean
+ disableSearchDropdown?: boolean
onBrowse: (options: BrowseOptions) => void
onClearFilters: typeof clearFilters
onOpenFiltersModal: () => ReturnType
diff --git a/webapp/src/components/NamesPage/NamesPage.tsx b/webapp/src/components/NamesPage/NamesPage.tsx
index bd21c04bd..d64fb6e32 100644
--- a/webapp/src/components/NamesPage/NamesPage.tsx
+++ b/webapp/src/components/NamesPage/NamesPage.tsx
@@ -9,7 +9,13 @@ import { PageLayout } from '../PageLayout'
const NamesPage = () => {
return (
-
+
)
}
diff --git a/webapp/src/modules/routing/selectors.spec.ts b/webapp/src/modules/routing/selectors.spec.ts
index 49aa9d28a..d94dddb47 100644
--- a/webapp/src/modules/routing/selectors.spec.ts
+++ b/webapp/src/modules/routing/selectors.spec.ts
@@ -157,6 +157,12 @@ describe('when getting if the are filters set', () => {
})
describe('when getting the section', () => {
+ describe("and there's no section URL param and the location is related to names", () => {
+ it("should return the decentraland's ENS section", () => {
+ expect(getSection.resultFunc('', locations.names(), VendorName.DECENTRALAND)).toBe(Sections.decentraland.ENS)
+ })
+ })
+
describe("when there's no section URL param and the location is related to lands", () => {
it("should return the decentraland's LAND section", () => {
expect(getSection.resultFunc('', locations.lands(), VendorName.DECENTRALAND)).toBe(Sections.decentraland.LAND)
diff --git a/webapp/src/modules/routing/selectors.ts b/webapp/src/modules/routing/selectors.ts
index 000c9174b..c5fdbf904 100644
--- a/webapp/src/modules/routing/selectors.ts
+++ b/webapp/src/modules/routing/selectors.ts
@@ -39,6 +39,10 @@ export const getSection = createSelector