From cfd6abd4b649ade24404bec997f5bff2c5eb2c9e Mon Sep 17 00:00:00 2001
From: Tobias Kohr <tobias.kohr@camptocamp.com>
Date: Mon, 8 Jan 2024 16:39:24 +0100
Subject: [PATCH 1/2] fix(organisations): fix org filtering to work with
 pagination

---
 apps/datahub-e2e/src/e2e/organizations.cy.ts           | 10 ++++++++++
 .../lib/organisations/organisations.component.spec.ts  | 10 ++++++++++
 .../src/lib/organisations/organisations.component.ts   |  1 +
 3 files changed, 21 insertions(+)

diff --git a/apps/datahub-e2e/src/e2e/organizations.cy.ts b/apps/datahub-e2e/src/e2e/organizations.cy.ts
index 7a5e521697..f9f0d19ffe 100644
--- a/apps/datahub-e2e/src/e2e/organizations.cy.ts
+++ b/apps/datahub-e2e/src/e2e/organizations.cy.ts
@@ -173,5 +173,15 @@ describe('organizations', () => {
       cy.get('@organisationsSearch').type('An organisation that does not exist')
       cy.get('@organisationsResult').should('contain', 'No organizations found')
     })
+    it('should display filtered results after navigation to second page', () => {
+      cy.get('@pagination').children('div').first().find('gn-ui-button').click()
+      cy.get('@organisationsSearch').type('geo2france')
+      cy.get('@organizationsName').should('have.length', 1)
+      cy.get('@organisationsResult').should('contain', '1')
+      cy.get('@organizationsName')
+        .eq(0)
+        .invoke('text')
+        .should('contain', 'Géo2France')
+    })
   })
 })
diff --git a/libs/feature/catalog/src/lib/organisations/organisations.component.spec.ts b/libs/feature/catalog/src/lib/organisations/organisations.component.spec.ts
index b115c8f8d7..582016fe91 100644
--- a/libs/feature/catalog/src/lib/organisations/organisations.component.spec.ts
+++ b/libs/feature/catalog/src/lib/organisations/organisations.component.spec.ts
@@ -162,6 +162,16 @@ describe('OrganisationsComponent', () => {
               .name
           ).toEqual('J Data Org')
         })
+        it('should not change currentPage when sorting results', () => {
+          component.setSortBy('desc')
+          fixture.detectChanges()
+          expect(paginationComponentDE.componentInstance.currentPage).toEqual(2)
+        })
+        it('should set currentPage to 1 when filtering to display results', () => {
+          component.setFilterBy('Data')
+          fixture.detectChanges()
+          expect(paginationComponentDE.componentInstance.currentPage).toEqual(1)
+        })
       })
     })
     describe('sort by recordCount', () => {
diff --git a/libs/feature/catalog/src/lib/organisations/organisations.component.ts b/libs/feature/catalog/src/lib/organisations/organisations.component.ts
index ecfc0418bb..a6be8656d6 100644
--- a/libs/feature/catalog/src/lib/organisations/organisations.component.ts
+++ b/libs/feature/catalog/src/lib/organisations/organisations.component.ts
@@ -74,6 +74,7 @@ export class OrganisationsComponent {
   }
 
   protected setFilterBy(value: string): void {
+    this.currentPage$.next(1)
     this.filterBy$.next(value)
   }
 

From fb45908cf580b9158007f272c231f7707df456e5 Mon Sep 17 00:00:00 2001
From: Tobias Kohr <tobias.kohr@camptocamp.com>
Date: Mon, 8 Jan 2024 16:40:47 +0100
Subject: [PATCH 2/2] fix(link-card): remove small visual glitch

---
 libs/ui/elements/src/lib/link-card/link-card.component.html | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libs/ui/elements/src/lib/link-card/link-card.component.html b/libs/ui/elements/src/lib/link-card/link-card.component.html
index 28213baca9..8f87410c66 100644
--- a/libs/ui/elements/src/lib/link-card/link-card.component.html
+++ b/libs/ui/elements/src/lib/link-card/link-card.component.html
@@ -5,7 +5,7 @@
 >
   <div class="max-h-24 overflow-hidden text-ellipsis">
     <p
-      class="font-title font-medium text-21 text-black break-words pb-1 line-clamp-2"
+      class="font-title font-medium text-21 text-black break-words mb-1 line-clamp-2"
     >
       {{ link.name }}
     </p>