Openverse is a search engine for openly-licensed media. This monorepo includes all application code.
Implement the composite search bar for the mobile search header (#1875)
Olga Bulat8795c64d1f52
diff --git a/src/components/VButton.vue b/src/components/VButton.vueindex 0068dc857..07bc640a6 100644--- a/src/components/VButton.vue+++ b/src/components/VButton.vue@@ -2,7 +2,7 @@<Component:is="as":type="typeRef"- class="flex appearance-none items-center justify-center rounded-sm no-underline ring-offset-1 transition-shadow duration-100 ease-linear focus:outline-none"+ class="group flex appearance-none items-center justify-center rounded-sm no-underline ring-offset-1 transition-shadow duration-100 ease-linear focus:outline-none":class="[$style.button,$style[variant],diff --git a/src/components/VHeader/VHeaderDesktop.vue b/src/components/VHeader/VHeaderDesktop.vueindex d5a91836e..8398375bd 100644--- a/src/components/VHeader/VHeaderDesktop.vue+++ b/src/components/VHeader/VHeaderDesktop.vue@@ -7,7 +7,7 @@: 'border-white'">- <VLogoButton :is-fetching="isFetching" :is-search-route="true" />+ <VLogoButton :is-fetching="isFetching" /><VSearchBarref="searchBarRef"diff --git a/src/components/VHeader/VHeaderInternal.vue b/src/components/VHeader/VHeaderInternal.vueindex 411c75327..639c0de8d 100644--- a/src/components/VHeader/VHeaderInternal.vue+++ b/src/components/VHeader/VHeaderInternal.vue@@ -93,7 +93,7 @@ export default defineComponent({name: 'VHeaderInternal',components: { VHomeLink, VIconButton, VLink, VModal, VPageLinks, WordPress },setup() {- const menuButtonRef = ref<InstanceType<typeof VIconButton>>(null)+ const menuButtonRef = ref<InstanceType<typeof VIconButton> | null>(null)const { all: allPages, current: currentPage } = usePages(true)const route = useRoute()diff --git a/src/components/VHeader/VHeaderMobile/VContentSettingsButton.vue b/src/components/VHeader/VHeaderMobile/VContentSettingsButton.vueindex 501453c42..c086bd4e0 100644--- a/src/components/VHeader/VHeaderMobile/VContentSettingsButton.vue+++ b/src/components/VHeader/VHeaderMobile/VContentSettingsButton.vue@@ -1,36 +1,32 @@<template>- <span class="relative inline-block h-8 w-8">- <VIconButton- size="new-small"- :icon-props="{ iconPath: sourceIcon }"- :button-props="{ variant: 'menu' }"- :aria-label="- areFiltersSelected- ? $t('header.aria.menu-notification')- : $t('header.aria.menu')- "- aria-haspopup="dialog"- :aria-expanded="isPressed"- aria-controls="content-settings-modal"- @click="$emit('click')"- />- <span- v-if="areFiltersSelected"- class="absolute top-[-2px] right-[-2px] h-[8px] w-[8px] rounded bg-pink"- />- </span>+ <VSearchBarButton+ :icon-path="sourceIcon"+ :aria-label="+ areFiltersSelected+ ? $t('header.aria.menu-notification')+ : $t('header.aria.menu')+ "+ aria-haspopup="dialog"+ :aria-expanded="isPressed"+ aria-controls="content-settings-modal"+ inner-area-classes="bg-white hover:bg-dark-charcoal hover:text-white"+ >+ <template #notification>+ <span+ v-if="areFiltersSelected"+ class="absolute top-[-2px] right-[-2px] h-[8px] w-[8px] rounded bg-pink"+ />+ </template>+ </VSearchBarButton></template>-<script lang="ts">-import { defineEvent } from '~/types/emits'--import VIconButton from '~/components/VIconButton/VIconButton.vue'+import VSearchBarButton from '~/components/VHeader/VHeaderMobile/VSearchBarButton.vue'import sourceIcon from '~/assets/icons/source.svg'export default {name: 'VContentSettingsButton',- components: { VIconButton },+ components: { VSearchBarButton },props: {isPressed: {type: Boolean,@@ -41,12 +37,9 @@ export default {default: false,},},- emits: {- click: defineEvent(),- },setup() {return {- sourceIcon,+ sourceIcon: sourceIcon as unknown as string,}},}diff --git a/src/components/VHeader/VHeaderMobile/VContentSettingsModal.vue b/src/components/VHeader/VHeaderMobile/VContentSettingsModal.vueindex a44372b9e..9032484ae 100644--- a/src/components/VHeader/VHeaderMobile/VContentSettingsModal.vue+++ b/src/components/VHeader/VHeaderMobile/VContentSettingsModal.vue@@ -9,8 +9,8 @@<template #trigger="{ visible, a11Props }"><VContentSettingsButton:is-pressed="visible"+ :are-filters-selected="areFiltersSelected"v-bind="a11Props"- class="me-2"/></template><VTabs@@ -111,6 +111,9 @@ export default defineComponent({const changeSelectedTab = (tab: 'content-settings' | 'filters') => {selectedTab.value = tab}++ const areFiltersSelected = computed(() => searchStore.isAnyFilterApplied)+const showClearFiltersButton = computed(() => selectedTab.value === 'filters')@@ -141,6 +144,7 @@ export default defineComponent({selectedTab,changeSelectedTab,+ areFiltersSelected,showClearFiltersButton,isClearButtonDisabled,clearFiltersLabel,diff --git a/src/components/VHeader/VHeaderMobile/VHeaderMobile.vue b/src/components/VHeader/VHeaderMobile/VHeaderMobile.vueindex b2af3f04e..f70b569e1 100644--- a/src/components/VHeader/VHeaderMobile/VHeaderMobile.vue+++ b/src/components/VHeader/VHeaderMobile/VHeaderMobile.vue@@ -1,27 +1,99 @@<template><header- class="main-header z-30 flex w-full items-center justify-between gap-x-2 bg-white px-4 py-3 md:items-stretch md:py-4 md:px-7"- :class="{- 'border-b border-white': !isHeaderScrolled && !isMenuOpen,- 'border-b border-dark-charcoal-20': isHeaderScrolled || isMenuOpen,- }"+ class="main-header z-30 flex w-full items-center border-b border-tx bg-white px-6 py-4"+ :class="{ 'border-dark-charcoal-20': isHeaderScrolled }">- <VLogoButton :is-fetching="isFetching" :is-search-route="isSearchRoute" />-- <VSearchBar- v-model.trim="searchTerm"- class="flex-grow"- size="medium"- @submit="handleSearch"+ <VInputModal+ class="flex w-full"+ variant="recent-searches"+ :is-active="isRecentSearchesModalOpen"+ @close="deactivate">- <span- v-show="searchStatus"- class="info mx-4 hidden whitespace-nowrap text-xs font-semibold text-dark-charcoal-70 group-hover:text-dark-charcoal group-focus:text-dark-charcoal"- >- {{ searchStatus }}- </span>- </VSearchBar>- <VContentSettingsModal :is-fetching="isFetching" />+ <div class="flex w-full" :class="isRecentSearchesModalOpen ? 'px-2' : ''">+ <form+ class="search-bar group flex h-12 w-full flex-row items-center overflow-hidden rounded-sm"+ :class="+ searchBarIsActive+ ? 'bg-white ring ring-pink'+ : 'bg-dark-charcoal-06'+ "+ @submit.prevent="handleSearch"+ >+ <slot name="start">+ <VLogoButton+ v-show="!searchBarIsActive"+ :is-fetching="isFetching"+ :is-search-route="true"+ class="w-12"+ />+ <VSearchBarButton+ v-show="searchBarIsActive"+ :icon-path="chevronLeftIcon"+ :inner-size="8"+ :aria-label="$t('header.back-button')"+ :rtl-flip="true"+ inner-area-classes="bg-dark-charcoal-10 hover:bg-dark-charcoal hover:text-white"+ @click="handleBack"+ />+ </slot>++ <input+ id="search-bar"+ ref="searchInputRef"+ name="q"+ :placeholder="$t('hero.search.placeholder').toString()"+ type="search"+ class="search-field h-full w-full flex-grow appearance-none rounded-none border-tx bg-tx text-2xl text-dark-charcoal-70 placeholder-dark-charcoal-70 ms-1 hover:text-dark-charcoal hover:placeholder-dark-charcoal focus-visible:outline-none"+ :value="searchTerm"+ :aria-label="+ $t('search.search-bar-label', {+ openverse: 'Openverse',+ }).toString()+ "+ autocomplete="off"+ role="combobox"+ aria-autocomplete="none"+ :aria-expanded="showRecentSearches"+ aria-controls="recent-searches-list"+ :aria-activedescendant="+ selectedIdx !== undefined ? `option-${selectedIdx}` : undefined+ "+ @input="updateSearchText"+ @focus="activate"+ @keydown="handleKeydown"+ />+ <slot>+ <VSearchBarButton+ v-show="searchBarIsActive && searchTerm"+ :icon-path="closeIcon"+ :aria-label="$t('browse-page.search-form.clear')"+ inner-area-classes="bg-white hover:bg-dark-charcoal-10"+ @click="clearSearchText"+ />+ <span+ v-show="!searchBarIsActive && searchStatus"+ class="info mx-4 hidden whitespace-nowrap text-xs group-hover:text-dark-charcoal group-focus:text-dark-charcoal md:flex"+ >+ {{ searchStatus }}+ </span>+ <VContentSettingsModal+ v-show="!searchBarIsActive"+ :is-fetching="isFetching"+ />+ </slot>+ </form>+ </div>++ <VRecentSearches+ v-show="showRecentSearches"+ :selected-idx="selectedIdx"+ :entries="entries"+ :bordered="false"+ class="mt-4"+ @select="handleSelect"+ @clear="handleClear"+ />+ </VInputModal></header></template>@@ -30,81 +102,64 @@ import {computed,defineComponent,inject,+ nextTick,ref,useContext,useRouter,+ watch,} from '@nuxtjs/composition-api'-import { ALL_MEDIA, searchPath } from '~/constants/media'-import { useMatchSearchRoutes } from '~/composables/use-match-routes'+import { ensureFocus } from '~/utils/reakit-utils/focus'+import { cyclicShift } from '~/utils/math'++import { searchPath } from '~/constants/media'+import { keycodes } from '~/constants/key-codes'++import { IsHeaderScrolledKey } from '~/types/provides'+import { useI18n } from '~/composables/use-i18n'import { useI18nResultsCount } from '~/composables/use-i18n-utilities'+import { useMediaStore } from '~/stores/media'import { isSearchTypeSupported, useSearchStore } from '~/stores/search'-import { IsHeaderScrolledKey, IsMinScreenMdKey } from '~/types/provides'-import VLogoButton from '~/components/VHeader/VLogoButton.vue'-import VModal from '~/components/VModal/VModal.vue'-import VSearchBar from '~/components/VHeader/VSearchBar/VSearchBar.vue'-+import VInputModal from '~/components/VModal/VInputModal.vue'import VContentSettingsModal from '~/components/VHeader/VHeaderMobile/VContentSettingsModal.vue'+import VRecentSearches from '~/components/VRecentSearches/VRecentSearches.vue'+import VSearchBarButton from '~/components/VHeader/VHeaderMobile/VSearchBarButton.vue'-import closeIcon from '~/assets/icons/close.svg'--const menus = {- FILTERS: 'filters',- CONTENT_SWITCHER: 'content-switcher',-}-type HeaderMenu = 'filters' | 'content-switcher'+import closeIcon from '~/assets/icons/close-small.svg'+import chevronLeftIcon from '~/assets/icons/chevron-left.svg'/**- * The mobile search header component.+ * Displays a text field for a search query and is attached to an action button+ * that fires a search request. The loading state and number of hits are also+ * displayed in the bar itself.*/export default defineComponent({name: 'VHeaderMobile',components: {VContentSettingsModal,+ VInputModal,VLogoButton,- VSearchBar,+ VRecentSearches,+ VSearchBarButton,},setup() {- const contentSettingsModalRef = ref<InstanceType<typeof VModal> | null>(- null- )+ const searchInputRef = ref<HTMLInputElement | null>(null)+const mediaStore = useMediaStore()const searchStore = useSearchStore()const { app } = useContext()const i18n = useI18n()const router = useRouter()- const { matches: isSearchRoute } = useMatchSearchRoutes()+ const searchBarIsActive = ref(false)const isHeaderScrolled = inject(IsHeaderScrolledKey)- const isMinScreenMd = inject(IsMinScreenMdKey)-- const openMenu = ref<null | HeaderMenu>(null)- const isMenuOpen = computed(() => openMenu.value !== null)-- const openMenuModal = (menuName: HeaderMenu) => {- if (openMenu.value !== null) {- close()- }- openMenu.value = menuName- }- const close = () => {- openMenu.value = null- }- const closeModal = () => {- if (contentSettingsModalRef.value) {- contentSettingsModalRef.value.close()- }- close()- }- const isFetching = computed(() => {- return mediaStore.fetchState.isFetching- })+ const isFetching = computed(() => mediaStore.fetchState.isFetching)const resultsCount = computed(() => mediaStore.resultCount)const { getI18nCount } = useI18nResultsCount()@@ -112,9 +167,9 @@ export default defineComponent({* Additional text at the end of the search bar.* Shows the loading state or result count.*/- const searchStatus = computed(() => {- if (!isSearchRoute.value || searchStore.searchTerm === '') return ''- if (isFetching.value) return i18n.t('header.loading')+ const searchStatus = computed<string>(() => {+ if (searchStore.searchTerm === '') return ''+ if (isFetching.value) return i18n.t('header.loading').toString()return getI18nCount(resultsCount.value)})@@ -153,21 +208,15 @@ export default defineComponent({window.scrollTo({ top: 0, left: 0, behavior: 'auto' })const mediaStore = useMediaStore()const searchStore = useSearchStore()- const searchType = isSearchRoute.value- ? searchStore.searchType- : ALL_MEDIA- if (- isSearchRoute.value &&- (!searchTermChanged.value || searchTerm.value === '')- )- return+ const searchType = searchStore.searchType+ if (!searchTermChanged.value || searchTerm.value === '') returnif (searchTermChanged.value) {await mediaStore.clearMedia()searchStore.setSearchTerm(searchTerm.value)searchStore.setSearchType(searchType)}- document.activeElement?.blur()+if (isSearchTypeSupported(searchType)) {const newPath = app.localePath({path: searchPath(searchType),@@ -175,33 +224,139 @@ export default defineComponent({})router.push(newPath)}+ deactivate()+ }++ const isRecentSearchesModalOpen = ref(false)++ const activate = () => (searchBarIsActive.value = true)+ const deactivate = () => {+ searchBarIsActive.value = false}- const areFiltersDisabled = computed(- () => !searchStore.searchTypeIsSupported++ watch(searchBarIsActive, (active) => {+ if (active) {+ isRecentSearchesModalOpen.value = true+ /**+ * Without `nextTick`, the search bar is not focused on click in Firefox+ */+ nextTick(() => {+ if (searchInputRef.value) ensureFocus(searchInputRef.value)+ })+ } else {+ isRecentSearchesModalOpen.value = false+ if (localSearchTerm.value === '' && searchStore.searchTerm !== '') {+ localSearchTerm.value = searchStore.searchTerm+ }+ }+ })++ const updateSearchText = (event: Event) => {+ searchTerm.value = (event.target as HTMLInputElement).value+ }++ const clearSearchText = () => {+ searchTerm.value = ''+ if (searchInputRef.value) {+ ensureFocus(searchInputRef.value)+ }+ }++ const handleBack = () => {+ deactivate()+ }++ /**+ * Refers to the current suggestion that has visual focus (not DOM focus)+ * and is the active descendant. This should be set to `undefined` when the+ * visual focus is on the input field.+ */+ const selectedIdx = ref<number | undefined>(undefined)+ const entries = computed(() => searchStore.recentSearches)+ const handleVerticalArrows = (event: KeyboardEvent) => {+ event.preventDefault() // Prevent the cursor from moving horizontally.+ const { key, altKey } = event+ // Show the recent searches.+ isRecentSearchesModalOpen.value = true+ if (altKey) return+ // Shift selection (if Alt was not pressed with arrow keys)+ let defaultValue: number+ let offset: number+ if (key == keycodes.ArrowUp) {+ defaultValue = 0+ offset = -1+ } else {+ defaultValue = -1+ offset = 1+ }+ selectedIdx.value = cyclicShift(+ selectedIdx.value ?? defaultValue,+ offset,+ 0,+ entries.value.length+ )+ }+ const handleOtherKeys = (event: KeyboardEvent) => {+ const { key } = event+ if (key === keycodes.Enter && selectedIdx.value)+ // If a recent search is selected, populate its value into the input.+ searchTerm.value = entries.value[selectedIdx.value]+ if (([keycodes.Escape] as string[]).includes(key))+ // Hide the recent searches.+ isRecentSearchesModalOpen.value = false+ selectedIdx.value = undefined // Lose visual focus from entries.+ }+ const handleKeydown = (event: KeyboardEvent) => {+ const { key } = event+ return ([keycodes.ArrowUp, keycodes.ArrowDown] as string[]).includes(key)+ ? handleVerticalArrows(event)+ : handleOtherKeys(event)+ }+ /* Populate the input with the clicked entry and execute the search. */+ const handleSelect = (idx: number) => {+ searchTerm.value = entries.value[idx]+ isRecentSearchesModalOpen.value = false+ selectedIdx.value = undefined // Lose visual focus from entries.+ handleSearch() // Immediately execute the search manually.+ }+ /* Clear all recent searches from the store. */+ const handleClear = () => {+ searchStore.clearRecentSearches()+ if (searchInputRef.value) {+ ensureFocus(searchInputRef.value)+ }+ }++ const showRecentSearches = computed(+ () => isRecentSearchesModalOpen.value && entries.value.length > 0)return {- closeIcon,- isFetching,+ chevronLeftIcon: chevronLeftIcon as unknown as string,+ closeIcon: closeIcon as unknown as string,+ searchInputRef,isHeaderScrolled,- isMinScreenMd,- isSearchRoute,- areFiltersDisabled,-- contentSettingsModalRef,-- closeModal,- openMenu,- openMenuModal,- isMenuOpen,+ isFetching,- menus,- close,+ isRecentSearchesModalOpen,+ showRecentSearches,+ searchBarIsActive,+ activate,+ deactivate,- handleSearch,searchStatus,searchTerm,+ clearSearchText,+ updateSearchText,+ handleSearch,++ handleBack,+ selectedIdx,+ entries,+ handleKeydown,+ handleSelect,+ handleClear,}},})diff --git a/src/components/VHeader/VHeaderMobile/VSearchBarButton.vue b/src/components/VHeader/VHeaderMobile/VSearchBarButton.vuenew file mode 100644index 000000000..ab52170ae--- /dev/null+++ b/src/components/VHeader/VHeaderMobile/VSearchBarButton.vue@@ -0,0 +1,52 @@+<template>+ <VIconButton+ size="search-medium"+ class="border-tx bg-tx"+ :button-props="{ variant: 'plain--avoid' }"+ v-on="$listeners"+ >+ <template #default="{ iconSize }">+ <span+ class="relative flex flex-shrink-0 flex-grow-0 items-center justify-center rounded-sm group-focus-visible:ring group-focus-visible:ring-pink group-active:ring group-active:ring-pink"+ :class="[`h-${innerSize} w-${innerSize}`, innerAreaClasses]"+ >+ <VIcon+ :icon-path="iconPath"+ :rtl-flip="rtlFlip"+ class="pointer-events-none"+ :size="iconSize"+ />+ <slot name="notification" />+ </span>+ </template>+ </VIconButton>+</template>+<script lang="ts">+import { defineComponent, PropType } from '@nuxtjs/composition-api'++import VIcon from '~/components/VIcon/VIcon.vue'+import VIconButton from '~/components/VIconButton/VIconButton.vue'++export default defineComponent({+ name: 'VSearchBarButton',+ components: { VIcon, VIconButton },+ props: {+ iconPath: {+ type: String,+ required: true,+ },+ innerSize: {+ type: Number as PropType<6 | 8>,+ default: 8,+ },+ innerAreaClasses: {+ type: String,+ default: '',+ },+ rtlFlip: {+ type: Boolean,+ default: false,+ },+ },+})+</script>diff --git a/src/components/VHeader/VLogoButton.vue b/src/components/VHeader/VLogoButton.vueindex b413b9ef6..c4cc8c632 100644--- a/src/components/VHeader/VLogoButton.vue+++ b/src/components/VHeader/VLogoButton.vue@@ -5,7 +5,8 @@:aria-label="$t('header.home-link')"variant="plain"size="disabled"- class="max-w-min text-dark-charcoal hover:bg-yellow"+ class="text-dark-charcoal hover:bg-yellow"+ :class="fixedSize ? 'h-12 w-12 flex-shrink-0' : 'max-w-min'"><VLogoLoader:status="isFetching ? 'loading' : 'idle'"@@ -27,13 +28,13 @@ export default defineComponent({type: Boolean,default: false,},- isSearchRoute: {+ autoResizeLogo: {type: Boolean,default: false,},- autoResizeLogo: {+ fixedSize: {type: Boolean,- default: true,+ default: false,},},})diff --git a/src/components/VHeader/meta/VHeaderMobile.stories.mdx b/src/components/VHeader/meta/VHeaderMobile.stories.mdxindex 2e50ee52d..3c64bc62a 100644--- a/src/components/VHeader/meta/VHeaderMobile.stories.mdx+++ b/src/components/VHeader/meta/VHeaderMobile.stories.mdx@@ -10,14 +10,6 @@ import VHeaderMobile from '~/components/VHeader/VHeaderMobile/VHeaderMobile.vue'<Metatitle="Components/VHeader/VHeaderMobile/VHeaderMobile"component={VHeaderMobile}- argTypes={{- input: {- action: 'input',- },- submit: {- action: 'submit',- },- }}/>export const Template = (args) => ({diff --git a/src/components/VModal/VInputModal.vue b/src/components/VModal/VInputModal.vuenew file mode 100644index 000000000..839b6bc2d--- /dev/null+++ b/src/components/VModal/VInputModal.vue@@ -0,0 +1,138 @@+<template>+ <div ref="nodeRef">+ <div v-if="!isActive" class="flex w-full"><slot /></div>+ <VTeleport v-else to="modal">+ <FocusTrap :initial-focus="() => false">+ <div+ class="fixed inset-0 z-40 flex min-h-screen w-full justify-center overflow-y-auto bg-white"+ >+ <div+ ref="dialogRef"+ v-bind="$attrs"+ class="flex w-full flex-col py-4 px-4"+ role="dialog"+ aria-modal="true"+ @keydown="onKeyDown"+ @blur="onBlur"+ >+ <slot />+ </div>+ </div>+ </FocusTrap>+ </VTeleport>+ </div>+</template>+<script lang="ts">+import {+ defineComponent,+ ref,+ watch,+ toRef,+ ComponentInstance,+} from '@nuxtjs/composition-api'++import { Portal as VTeleport } from 'portal-vue'+import { FocusTrap } from 'focus-trap-vue'++import { useBodyScrollLock } from '~/composables/use-body-scroll-lock'+import { useDialogContent } from '~/composables/use-dialog-content'++import type { SetupContext } from 'vue'++export default defineComponent({+ name: 'VInputModal',+ components: { VTeleport, FocusTrap },++ /**+ * NB: Most of these technically default to `undefined` so that the underlying `VPopoverContent`+ * default for each of them can take over.+ */+ props: {+ /**+ * This props allows for the modal to be opened or closed programmatically.+ * The modal handles the visibility internally if this prop is not provided.+ *+ * @default undefined+ */+ isActive: {+ type: Boolean,+ default: false,+ },+ },+ emits: [+ /**+ * Fires when the popover opens, regardless of reason. There are no extra parameters.+ */+ 'open',+ /**+ * Fires when the popover closes, regardless of reason. There are no extra parameters.+ */+ 'close',+ ],+ setup(props, { emit }) {+ const focusTrapRef = ref<ComponentInstance | null>(null)++ const visibleRef = toRef(props, 'isActive')+ const internalVisibleRef = ref<boolean>(+ props.isActive === undefined ? false : visibleRef.value+ )++ const nodeRef = ref<HTMLElement | null>(null)++ /**+ * When the `visible` prop is set to a different value than internalVisibleRef,+ * we update the internalVisibleRef to match the prop.+ */+ watch(visibleRef, (visible) => {+ if (visible === undefined || visible === internalVisibleRef.value) return++ if (visible) {+ open()+ } else {+ close()+ }+ })++ const { lock, unlock } = useBodyScrollLock({ nodeRef })++ const open = () => {+ internalVisibleRef.value = true+ lock()+ if (props.isActive !== internalVisibleRef.value) {+ emit('open')+ }+ }++ const close = () => {+ internalVisibleRef.value = false+ unlock()+ emit('close')+ }++ const dialogRef = ref<HTMLElement | null>(null)++ const { onKeyDown, onBlur } = useDialogContent({+ dialogRef,+ visibleRef: toRef(props, 'isActive'),+ autoFocusOnShowRef: ref(true),+ autoFocusOnHideRef: ref(false),+ triggerElementRef: ref(null),+ hideOnClickOutsideRef: ref(false),+ hideRef: ref(close),+ hideOnEscRef: ref(true),+ emit: emit as SetupContext['emit'],+ })++ return {+ focusTrapRef,+ dialogRef,+ nodeRef,+ internalVisibleRef,++ close,+ onKeyDown,+ onBlur,+ }+ },+})+</script>diff --git a/src/components/VRecentSearches/VRecentSearches.vue b/src/components/VRecentSearches/VRecentSearches.vueindex ee9ad928a..061e0e89d 100644--- a/src/components/VRecentSearches/VRecentSearches.vue+++ b/src/components/VRecentSearches/VRecentSearches.vue@@ -1,18 +1,21 @@<template><div- class="flex flex-col gap-1 rounded-sm border border-dark-charcoal-20 bg-white p-4 shadow-el-2"+ class="flex flex-col gap-1 rounded-sm border bg-white"+ :class="bordered ? 'border-dark-charcoal-20 p-4 shadow-el-2' : 'border-tx'"data-testid="recent-searches">- <div class="flex flex-row items-center justify-between py-2">+ <div+ class="flex flex-row items-center justify-between py-2"+ :class="{ 'pe-2': !bordered }"+ ><!-- Left margin to align with the text of recent searches. --><span class="category mx-2 my-1">{{ $t('recent-searches.heading') }}</span><VButtonv-show="entries.length"- variant="plain"- size="small"- class="caption-bold hover:underline"+ variant="text"+ class="caption-bold":aria-label="$t('recent-searches.clear.label').toString()"@click="handleClear">@@ -80,6 +83,13 @@ export default defineComponent({selectedIdx: {type: Number,},+ /**+ * the desktop popover is bordered, and the mobile element is not+ */+ bordered: {+ type: Boolean,+ default: true,+ },},emits: {select: defineEvent<[number]>(),diff --git a/src/composables/use-body-scroll-lock.ts b/src/composables/use-body-scroll-lock.tsindex 75cb01c5a..f0d26acd3 100644--- a/src/composables/use-body-scroll-lock.ts+++ b/src/composables/use-body-scroll-lock.ts@@ -1,19 +1,32 @@-import { Ref, ref } from '@nuxtjs/composition-api'+import { Ref, ref, watch } from '@nuxtjs/composition-api'import { getDocument } from '~/utils/reakit-utils/dom'/*** Creates a utility for locking body scrolling for a particular node.*/-export function useBodyScrollLock({ nodeRef }: { nodeRef: Ref<HTMLElement> }) {- const locked = ref(false)+export function useBodyScrollLock({+ nodeRef,+ initialLocked = false,+}: {+ nodeRef: Ref<HTMLElement | null>+ initialLocked?: boolean+}) {+ const locked = ref(initialLocked)let scrollY: number | null = null+ watch(+ nodeRef,+ (node) => {+ if (node && locked.value) lock()+ },+ {+ immediate: true,+ }+ )const lock = () => {if (!nodeRef.value) {- throw new Error(- 'useBodyScrollLock: Cannot lock body with undefined node reference'- )+ return}locked.value = true@@ -25,9 +38,7 @@ export function useBodyScrollLock({ nodeRef }: { nodeRef: Ref<HTMLElement> }) {const unlock = () => {if (!nodeRef.value) {- throw new Error(- 'useBodyScrollLock: Cannot unlock body with undefined node reference'- )+ return}locked.value = falsediff --git a/src/layouts/default.vue b/src/layouts/default.vueindex f71974ef8..8c618d304 100644--- a/src/layouts/default.vue+++ b/src/layouts/default.vue@@ -21,10 +21,10 @@isNewHeaderEnabled ? 'new-layout' : 'old-layout',]">- <div v-if="isNewHeaderEnabled">- <Nuxt class="main-page min-w-0" />+ <template v-if="isNewHeaderEnabled">+ <Nuxt class="main-page min-w-0 !px-6" /><VFooter class="border-t border-dark-charcoal-20" />- </div>+ </template><Nuxt v-else class="main-page min-w-0" /><VSidebarTargetdiff --git a/src/locales/en.json b/src/locales/en.jsonindex c82231f87..2711eb4bf 100644--- a/src/locales/en.json+++ b/src/locales/en.json@@ -59,7 +59,8 @@"simple": "Filters","with-count": "{count} Filter|{count} Filters"},- "see-results": "See results"+ "see-results": "See results",+ "back-button": "Go back"},"navigation": {"about": "About",diff --git a/tsconfig.json b/tsconfig.jsonindex 7d4a7b040..e1005c00a 100644--- a/tsconfig.json+++ b/tsconfig.json@@ -84,6 +84,7 @@"src/components/VHeader/VPageLinks.vue","src/components/VHeader/VSearchBar/**.vue","src/components/VImageDetails/VRelatedImages.vue",+ "src/components/VModal/VInputModal.vue","src/pages/feedback.vue","src/pages/search-help.vue","src/composables/types.js",