Skip to content

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

Focus the trigger when content setting modal is closed (#4338)

Olga Bulatac480fd8ccb9
diff --git a/frontend/src/components/VButton.vue b/frontend/src/components/VButton.vue
index 2d113a89e..7e5f1796d 100644
--- a/frontend/src/components/VButton.vue
+++ b/frontend/src/components/VButton.vue
@@ -12,6 +12,7 @@
'icon-start': hasIconStart,
'icon-end': hasIconEnd,
border: !isPlainDangerous,
+ 'focus-visible:outline-tx': isPlainDangerous,
'focus-slim-filled': isFocusSlimFilled,
'focus-slim-tx': isFocusSlimTx,
},
diff --git a/frontend/src/components/VHeader/VHeaderMobile/VContentSettingsButton.vue b/frontend/src/components/VHeader/VHeaderMobile/VContentSettingsButton.vue
index 7fa1e080b..c2359a1e3 100644
--- a/frontend/src/components/VHeader/VHeaderMobile/VContentSettingsButton.vue
+++ b/frontend/src/components/VHeader/VHeaderMobile/VContentSettingsButton.vue
@@ -22,9 +22,11 @@
</VSearchBarButton>
</template>
<script lang="ts">
+import { defineComponent } from "@nuxtjs/composition-api"
+
import VSearchBarButton from "~/components/VHeader/VHeaderMobile/VSearchBarButton.vue"
-export default {
+export default defineComponent({
name: "VContentSettingsButton",
components: { VSearchBarButton },
props: {
@@ -37,5 +39,5 @@ export default {
default: 0,
},
},
-}
+})
</script>
diff --git a/frontend/src/components/VHeader/VHeaderMobile/VContentSettingsModalContent.vue b/frontend/src/components/VHeader/VHeaderMobile/VContentSettingsModalContent.vue
index a053aac6b..ea4e5f435 100644
--- a/frontend/src/components/VHeader/VHeaderMobile/VContentSettingsModalContent.vue
+++ b/frontend/src/components/VHeader/VHeaderMobile/VContentSettingsModalContent.vue
@@ -5,6 +5,7 @@
:hide="close"
:visible="visible"
:variant="variant"
+ :trigger-element="triggerElement"
class="flex items-center"
>
<VTabs
@@ -121,6 +122,10 @@ export default defineComponent({
VTabs,
},
props: {
+ triggerElement: {
+ type: (process.server ? Object : HTMLElement) as PropType<HTMLElement>,
+ default: null,
+ },
variant: {
type: String as PropType<"fit-content" | "two-thirds">,
default: "fit-content",
diff --git a/frontend/src/components/VHeader/VHeaderMobile/VHeaderMobile.vue b/frontend/src/components/VHeader/VHeaderMobile/VHeaderMobile.vue
index a0e826a47..c97854145 100644
--- a/frontend/src/components/VHeader/VHeaderMobile/VHeaderMobile.vue
+++ b/frontend/src/components/VHeader/VHeaderMobile/VHeaderMobile.vue
@@ -78,6 +78,7 @@
</span>
<VContentSettingsButton
v-show="!searchBarIsActive"
+ ref="contentSettingsButtonRef"
:is-pressed="contentSettingsOpen"
:applied-filter-count="appliedFilterCount"
v-bind="triggerA11yProps"
@@ -90,6 +91,7 @@
:visible="contentSettingsOpen"
:is-fetching="isFetching"
:close="closeContentSettings"
+ :trigger-element="contentSettingsButton"
labelledby="content-settings-button"
/>
</slot>
@@ -153,6 +155,12 @@ export default defineComponent({
setup(_, { emit }) {
const searchInputRef = ref<HTMLInputElement | null>(null)
const headerRef = ref<HTMLElement | null>(null)
+ const contentSettingsButtonRef = ref<InstanceType<
+ typeof VContentSettingsButton
+ > | null>(null)
+ const contentSettingsButton = computed(
+ () => (contentSettingsButtonRef.value?.$el as HTMLElement) ?? undefined
+ )
const mediaStore = useMediaStore()
const searchStore = useSearchStore()
@@ -308,6 +316,8 @@ export default defineComponent({
return {
searchInputRef,
headerRef,
+ contentSettingsButtonRef,
+ contentSettingsButton,
isFetching,
diff --git a/frontend/src/components/VHeader/VHeaderMobile/VSearchBarButton.vue b/frontend/src/components/VHeader/VHeaderMobile/VSearchBarButton.vue
index 5e7a9ce5f..5c25e7de0 100644
--- a/frontend/src/components/VHeader/VHeaderMobile/VSearchBarButton.vue
+++ b/frontend/src/components/VHeader/VHeaderMobile/VSearchBarButton.vue
@@ -74,6 +74,12 @@ export default defineComponent({
</script>
<style scoped>
+.button {
+ accent-color: transparent;
+}
+.button:focus {
+ outline: none;
+}
.transparent-dark {
@apply border-tx bg-tx text-dark-charcoal hover:text-white group-hover/button:bg-dark-charcoal;
}
diff --git a/frontend/test/storybook/visual-regression/v-button.spec.ts-snapshots/plain--avoid-focused-hovered-linux.png b/frontend/test/storybook/visual-regression/v-button.spec.ts-snapshots/plain--avoid-focused-hovered-linux.png
index 05cef36c6..427486554 100644
Binary files a/frontend/test/storybook/visual-regression/v-button.spec.ts-snapshots/plain--avoid-focused-hovered-linux.png and b/frontend/test/storybook/visual-regression/v-button.spec.ts-snapshots/plain--avoid-focused-hovered-linux.png differ
diff --git a/frontend/test/storybook/visual-regression/v-button.spec.ts-snapshots/plain--avoid-focused-linux.png b/frontend/test/storybook/visual-regression/v-button.spec.ts-snapshots/plain--avoid-focused-linux.png
index 05cef36c6..427486554 100644
Binary files a/frontend/test/storybook/visual-regression/v-button.spec.ts-snapshots/plain--avoid-focused-linux.png and b/frontend/test/storybook/visual-regression/v-button.spec.ts-snapshots/plain--avoid-focused-linux.png differ