From e47fa9a4eb67bb7460a2355004430a083aca04f0 Mon Sep 17 00:00:00 2001
From: t11r <1674104+t11r@users.noreply.github.com>
Date: Sun, 1 Oct 2023 22:40:38 +0200
Subject: [PATCH] Fix button not closing popup, reduce redundancy
Since v-click-outside trumps touch listeners, we need to move the directive to a common parent element and change the DOM tree accordingly. Otherwise, the button does not close the popup on touch. Extend associated e2e tests.
The pagination buttons' DOM is now identical for large and small screens, so move them to a separate component.
---
src/components/AppHeader.vue | 401 +++++++++------------------
src/components/PaginationButtons.vue | 67 +++++
src/styles/sections/header.scss | 44 +--
tests/e2e/pagination.spec.js | 19 +-
4 files changed, 239 insertions(+), 292 deletions(-)
create mode 100644 src/components/PaginationButtons.vue
diff --git a/src/components/AppHeader.vue b/src/components/AppHeader.vue
index 06a98613..142b2d11 100644
--- a/src/components/AppHeader.vue
+++ b/src/components/AppHeader.vue
@@ -28,72 +28,13 @@
-
+
-
+
-
-
-
-
-
-
diff --git a/src/components/PaginationButtons.vue b/src/components/PaginationButtons.vue
new file mode 100644
index 00000000..24ee99c3
--- /dev/null
+++ b/src/components/PaginationButtons.vue
@@ -0,0 +1,67 @@
+
+
+
+
+
diff --git a/src/styles/sections/header.scss b/src/styles/sections/header.scss
index 6d6c7564..43a06ad7 100644
--- a/src/styles/sections/header.scss
+++ b/src/styles/sections/header.scss
@@ -30,20 +30,26 @@
.tify.-small & {
display: none;
}
+
+ .tify-header-popup & {
+ box-shadow: 0 -1px $border-color;
+ display: none;
+ margin: calc(#{$br} * 2 - 1px) 0 0;
+ padding: $br 0 0;
+
+ .tify.-small & {
+ display: flex;
+ }
+ }
}
- &.-popup {
- box-shadow: 0 -1px $border-color;
+ &.-toggle {
display: none;
- margin: calc(#{$br} * 2 - 1px) 0 0;
- padding: $br 0 0;
- .tify.-small & {
+ .tify.-large & {
display: flex;
}
- }
- &.-toggle {
.tify-header-column:not(:nth-child(2)) & {
border-left: 1px solid $border-color;
@@ -173,27 +179,21 @@
&:first-child {
flex: 1;
}
+}
- &.-toggle {
+.tify-header-popup {
+ display: flex;
+
+ .tify.-large & {
+ @include dropdown(right);
+ box-shadow: none;
display: none;
+ top: g(2);
- .tify.-large & {
+ &.-visible {
display: block;
}
}
-
- &.-controls {
- .tify.-large & {
- @include dropdown(right);
- box-shadow: none;
- display: none;
- top: g(2);
-
- &.-visible {
- display: block;
- }
- }
- }
}
.tify-header-title {
diff --git a/tests/e2e/pagination.spec.js b/tests/e2e/pagination.spec.js
index 67c92c12..3687d0ae 100644
--- a/tests/e2e/pagination.spec.js
+++ b/tests/e2e/pagination.spec.js
@@ -77,19 +77,24 @@ describe('Pagination', () => {
cy.contains('.-current.-highlighted', '69 : -');
});
- it('changes the page on a small touchscreen', () => {
+ it('changes the page on small touchscreens', () => {
cy.viewport(375, 667);
cy.visit(`/?manifest=${Cypress.env('iiifApiUrl')}/manifest/gdz-HANS_DE_7_w042081`);
cy.get('[title="View"]').click();
- cy.get('.tify-header-button-group.-popup [title="Last page"]').click();
- cy.get('.tify-header-button-group.-popup [title="Next page"]').should('be.disabled');
- cy.get('.tify-header-button-group.-popup [title="Next section"]').should('be.disabled');
- cy.get('.tify-header-button-group.-popup [title="Last page"]').should('be.disabled');
+ cy.contains('Pages').should('be.visible');
+ cy.get('[title="View"]').click();
+ cy.contains('Pages').should('not.be.visible');
+
+ cy.get('[title="View"]').click();
+ cy.get('.tify-header-popup [title="Last page"]').click();
+ cy.get('.tify-header-popup [title="Next page"]').should('be.disabled');
+ cy.get('.tify-header-popup [title="Next section"]').should('be.disabled');
+ cy.get('.tify-header-popup [title="Last page"]').should('be.disabled');
- cy.get('.tify-header-button-group.-popup [title="Previous section"]').click();
+ cy.get('.tify-header-popup [title="Previous section"]').click();
cy.contains(currentPage, '67 : -');
cy.get('.tify-header').click();
- cy.get('.tify-header-column.-controls').should('not.be.visible');
+ cy.get('.tify-header-popup').should('not.be.visible');
});
});