Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug(NoteManager): Fix search options dialog not overlapping some elements #1509

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 37 additions & 18 deletions client/src/game/ui/notes/NoteList.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { type DeepReadonly, computed, reactive, ref, watch } from "vue";
import { type DeepReadonly, computed, onMounted, onUnmounted, reactive, ref, watch } from "vue";

import { arrToToggleGroup } from "../../../core/components/toggleGroup";
import ToggleGroup from "../../../core/components/ToggleGroup.vue";
Expand Down Expand Up @@ -29,6 +29,7 @@ const searchFilters = reactive({
});

const searchBar = ref<HTMLInputElement | null>(null);
const searchOptionsDialog = ref<HTMLDivElement | null>(null);
const searchFilter = ref("");
const showSearchFilters = ref(false);
const searchPage = ref(1);
Expand All @@ -45,6 +46,22 @@ const shapeName = computed(() => {
// searchBar.value?.focus();
// });

function handleClickOutsideDialog(event: MouseEvent): void {
if (searchOptionsDialog.value) {
if (showSearchFilters.value && !searchOptionsDialog.value.contains(event.target as Node)) {
showSearchFilters.value = false;
}
}
}

onMounted(() => {
document.addEventListener('pointerdown', handleClickOutsideDialog);
});

onUnmounted(() => {
document.removeEventListener('pointerdown', handleClickOutsideDialog);
});

const noteArray = computed(() => {
let it: Iterable<DeepReadonly<ClientNote>> = noteState.reactive.notes.values();
if (!searchFilters.includeArchivedLocations) {
Expand Down Expand Up @@ -146,7 +163,18 @@ function clearSearchBar(): void {
<input ref="searchBar" v-model="searchFilter" type="text" placeholder="search through your notes.." />
<font-awesome-icon v-show="searchFilter.length > 0" id="clear-button" icon="circle-xmark" title="Clear Search" @click.stop="clearSearchBar" />
</div>
<div v-show="showSearchFilters" id="search-filter">
<font-awesome-icon
id="search-options-icon"
icon="sliders"
style="opacity: 0.5"
@click="showSearchFilters = true"
/>
<div v-show="showSearchFilters" id="search-filter" ref="searchOptionsDialog">
<font-awesome-icon
id="search-options-close-icon"
icon="sliders"
@click="showSearchFilters = false"
/>
<fieldset>
<legend>Where to search</legend>
<div>
Expand Down Expand Up @@ -212,13 +240,6 @@ function clearSearchBar(): void {
</div>
</fieldset>
</div>
<div id="search-icons">
<font-awesome-icon
icon="sliders"
:style="{ opacity: showSearchFilters ? 1 : 0.5 }"
@click="showSearchFilters = !showSearchFilters"
/>
</div>
</div>
</div>
<template v-if="visibleNotes.notes.length === 0">
Expand Down Expand Up @@ -335,10 +356,10 @@ header {
> #search-field {
flex-grow: 1;
flex-shrink: 1;
padding-right: 4rem;

outline: none;
border: none;
border-radius: 1rem;

display: flex;
align-items: center;
Expand All @@ -358,21 +379,19 @@ header {
font-size: 1rem;
cursor: pointer;
}

}

> #search-icons {
position: absolute;
display: flex;
right: 1.5rem;
> #search-options-icon {
margin: 0 1rem;
}

#search-filter-toggle {
#search-options-close-icon {
position: absolute;
right: 1.5rem;
right: 1rem;
top: 0.7rem;
}

#search-filter {
z-index: 1;
position: absolute;
top: -2px;
right: -2px;
Expand Down