Skip to content

Openverse is a search engine for openly-licensed media. This monorepo includes all application code.

Fix whitespace bug that only affected Chrome (#2682)

Dhruv Bhanushali6f2e34dec943
diff --git a/frontend/src/components/VBrand/VBrand.vue b/frontend/src/components/VBrand/VBrand.vue
index ce76c6427..24a53fe74 100644
--- a/frontend/src/components/VBrand/VBrand.vue
+++ b/frontend/src/components/VBrand/VBrand.vue
@@ -1,38 +1,27 @@
<template>
- <!-- Using `flex` to center the group of SVGs inside the bounding box. -->
- <div class="flex flex-row items-center">
- <!-- Using `flex` to place two SVGs side by side. -->
- <span class="inline-flex h-[1em] flex-row gap-[0.4em]" aria-hidden="true">
- <VSvg class="h-full w-auto" viewBox="0 0 50 42" name="logo" />
- <VSvg class="h-full w-auto" viewBox="0 0 215 42" name="brand" />
- </span>
- <span v-if="srText" class="sr-only">{{ srText }}</span>
- </div>
+ <!-- Using `flex` to place two SVGs side by side, centered. -->
+ <span
+ class="flex h-[1em] flex-row items-center gap-x-[0.4em]"
+ aria-hidden="true"
+ >
+ <VSvg class="h-full w-auto" viewBox="0 0 50 42" name="logo" />
+ <VSvg class="h-full w-auto" viewBox="0 0 215 42" name="brand" />
+ </span>
</template>
<script lang="ts">
import { defineComponent } from "vue"
import VSvg from "~/components/VSvg/VSvg.vue"
+
/**
- * Render the openverse logo and wordmark next to each other, while being
- * accessible to screen-readers.
+ * A simple Openverse logo component, visually hidden from screen-reader users.
+ * Implementations should wrap this icon with appropriate sr-only text or an aria-label.
*/
export default defineComponent({
name: "VBrand",
components: {
VSvg,
},
- props: {
- /**
- * the screen-reader text to put inside the component; Can be set to a blank
- * string to not read anything at all.
- */
- srText: {
- type: String,
- required: false,
- default: "Openverse",
- },
- },
})
</script>
diff --git a/frontend/src/components/VFooter/VFooter.vue b/frontend/src/components/VFooter/VFooter.vue
index 42adc465f..efb71ab9c 100644
--- a/frontend/src/components/VFooter/VFooter.vue
+++ b/frontend/src/components/VFooter/VFooter.vue
@@ -9,7 +9,7 @@
>
<!-- Logo and links -->
<div v-if="isContentMode" class="logo-and-links flex flex-col gap-y-10">
- <VLink href="/" class="logo text-dark-charcoal">
+ <VLink href="/" class="logo text-dark-charcoal" aria-label="Openverse">
<VBrand class="text-[18px]" />
</VLink>
<nav>
diff --git a/frontend/test/playwright/e2e/search.spec.ts b/frontend/test/playwright/e2e/search.spec.ts
index 678c74765..87f0598ae 100644
--- a/frontend/test/playwright/e2e/search.spec.ts
+++ b/frontend/test/playwright/e2e/search.spec.ts
@@ -29,12 +29,17 @@ test("shows no results page when no results", async ({ page }) => {
test("scroll to top on new search term submitted", async ({ page }) => {
await goToSearchTerm(page, "galah")
await scrollToBottom(page)
- let scrollY = await page.evaluate(() => window.scrollY)
+
+ let scrollY = await page.evaluate(
+ () => document.getElementById("main-page")?.scrollTop
+ )
expect(scrollY).not.toBe(0)
await searchFromHeader(page, "honey")
- scrollY = await page.evaluate(() => window.scrollY)
+ scrollY = await page.evaluate(
+ () => document.getElementById("main-page")?.scrollTop
+ )
expect(scrollY).toBe(0)
})
diff --git a/frontend/test/playwright/utils/navigation.ts b/frontend/test/playwright/utils/navigation.ts
index b2efcfb4e..99f0e1ea0 100644
--- a/frontend/test/playwright/utils/navigation.ts
+++ b/frontend/test/playwright/utils/navigation.ts
@@ -358,25 +358,35 @@ export const getLocatorHref = async (locator: Locator) => {
return href
}
-export const scrollToBottom = async (page: Page) => {
- // On search page, scroll the main page and not the window.
- const mainScrollHeight = await page.evaluate(
- () => document.getElementById("main-page")?.scrollHeight ?? 0
- )
- await page.mouse.wheel(0, mainScrollHeight)
-
- await page.evaluate(() => {
- window.scrollTo(0, document.body.scrollHeight)
- })
+/**
+ * Scroll the site to the "end" (top or bottom) of the primary scrollable element, either:
+ * - the `window`, on interior pages
+ * - the `#main-page`, on search views
+ *
+ * This is necessary because on search views the window itself doesnt scroll, only
+ * its child elements (the search result area + the filter sidebar).
+ *
+ * This function will scroll both elements on every evocation.
+ */
+export const fullScroll = async (
+ page: Page,
+ direction: "bottom" | "top" = "bottom"
+) => {
+ await page.evaluate((direction) => {
+ const mainPage = document.getElementById("main-page")
+ mainPage?.scrollTo(0, direction === "top" ? 0 : mainPage?.scrollHeight)
+ window.scrollTo(0, direction === "top" ? 0 : document.body.scrollHeight)
+ }, direction)
}
export const scrollToTop = async (page: Page) => {
- await page.evaluate(() => {
- // On search page, scroll the main page and not the window.
- document.getElementById("main-page")?.scrollTo(0, 0)
- window.scrollTo(0, 0)
- })
- await sleep(200)
+ await fullScroll(page, "top")
+ await sleep(200) // TODO: Is this necessary?
+}
+
+export const scrollToBottom = async (page: Page) => {
+ await fullScroll(page, "bottom")
+ await sleep(200) // TODO: Is this necessary?
}
/**