Skip to content

Commit

Permalink
Add ability to close tooltip with escape button
Browse files Browse the repository at this point in the history
  • Loading branch information
CronkCode committed Sep 10, 2024
1 parent 73f6ba7 commit 997076a
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 3 deletions.
8 changes: 7 additions & 1 deletion src/ui/UserPortal/components/ChatInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div class="input-wrapper">
<div class="tooltip-component">
<VTooltip :auto-hide="isMobile" :popper-triggers="isMobile ? [] : ['hover']">
<i class="pi pi-info-circle" tabindex="0"></i>
<i class="pi pi-info-circle" tabindex="0" @keydown.esc="hideAllPoppers"></i>
<template #popper> Use Shift+Enter to add a new line </template>
</VTooltip>
</div>
Expand All @@ -16,6 +16,7 @@
class="file-upload-button secondary-button"
style="height: 100%"
@click="showFileUploadDialog = true"
@keydown.esc="hideAllPoppers"
/>
<template #popper>
Attach files ({{
Expand Down Expand Up @@ -182,6 +183,7 @@
<script lang="ts">
import { Mentionable } from 'vue-mention';
import 'floating-vue/dist/style.css';
import { hideAllPoppers } from 'floating-vue';
export default {
name: 'ChatInput',
Expand Down Expand Up @@ -387,6 +389,10 @@ export default {
}
});
},
hideAllPoppers() {
hideAllPoppers();
},
},
};
</script>
Expand Down
9 changes: 8 additions & 1 deletion src/ui/UserPortal/components/ChatMessage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
}"
/>
<VTooltip :auto-hide="isMobile" :popper-triggers="isMobile ? [] : ['hover']">
<span class="time-stamp" tabindex="0">{{
<span class="time-stamp" tabindex="0" @keydown.esc="hideAllPoppers">{{
$filters.timeAgo(new Date(message.timeStamp))
}}</span>
<template #popper>
Expand All @@ -46,6 +46,7 @@
icon="pi pi-copy"
aria-label="Copy Message"
@click.stop="handleCopyMessageContent"
@keydown.esc="hideAllPoppers"
/>
<template #popper>Copy Message</template>
</VTooltip>
Expand Down Expand Up @@ -210,6 +211,8 @@ import { fetchBlobUrl } from '@/js/fileService';
import CodeBlockHeader from '@/components/CodeBlockHeader.vue';
import ChatMessageContentBlock from '@/components/ChatMessageContentBlock.vue';
import { hideAllPoppers } from 'floating-vue';
function processLatex(content) {
const blockLatexPattern = /\\\[\s*([\s\S]+?)\s*\\\]/g;
const inlineLatexPattern = /\\\(([\s\S]+?)\\\)/g;
Expand Down Expand Up @@ -483,6 +486,10 @@ export default {
this.viewPrompt = true;
},
hideAllPoppers() {
hideAllPoppers();
},
handleFileLinkInText(event: MouseEvent) {
const link = (event.target as HTMLElement).closest('a.file-download-link');
if (link && link.dataset.href) {
Expand Down
11 changes: 10 additions & 1 deletion src/ui/UserPortal/components/ChatSidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
class="secondary-button"
aria-label="Toggle sidebar"
@click="$appStore.toggleSidebar"
@keydown.esc="hideAllPoppers"
/>
<template #popper>Toggle sidebar</template>
</VTooltip>
Expand All @@ -30,6 +31,7 @@
aria-label="Add new chat"
:disabled="createProcessing"
@click="handleAddSession"
@keydown.esc="hideAllPoppers"
/>
<template #popper>Add new chat</template>
</VTooltip>
Expand All @@ -49,7 +51,7 @@
<!-- Chat name -->

<VTooltip :auto-hide="isMobile" :popper-triggers="isMobile ? [] : ['hover']">
<span class="chat__name" tabindex="0">{{ session.name }}</span>
<span class="chat__name" tabindex="0" @keydown.esc="hideAllPoppers">{{ session.name }}</span>
<template #popper>
{{ session.name }}
</template>
Expand All @@ -66,6 +68,7 @@
text
aria-label="Rename chat session"
@click.stop="openRenameModal(session)"
@keydown.esc="hideAllPoppers"
/>
<template #popper> Rename chat session </template>
</VTooltip>
Expand All @@ -79,6 +82,7 @@
text
aria-label="Delete chat session"
@click.stop="sessionToDelete = session"
@keydown.esc="hideAllPoppers"
/>
<template #popper> Delete chat session </template>
</VTooltip>
Expand Down Expand Up @@ -168,6 +172,7 @@

<script lang="ts">
import type { Session } from '@/js/types';
import { hideAllPoppers } from 'floating-vue';
declare const process: any;
export default {
Expand Down Expand Up @@ -273,6 +278,10 @@ export default {
this.sessionToDelete = null;
}
},
hideAllPoppers() {
hideAllPoppers();
},
},
};
</script>
Expand Down
7 changes: 7 additions & 0 deletions src/ui/UserPortal/components/NavBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
class="secondary-button"
aria-label="Toggle sidebar"
@click="$appStore.toggleSidebar"
@keydown.esc="hideAllPoppers"
/>
<template #popper>Toggle sidebar</template>
</VTooltip>
Expand Down Expand Up @@ -62,6 +63,7 @@
:src="$appConfigStore.agentIconUrl || '~/assets/FLLM-Agent-Light.svg'"
alt="Select an agent"
tabindex="0"
@keydown.esc="hideAllPoppers"
/>
<template #popper> Select an agent </template>
</VTooltip>
Expand All @@ -87,6 +89,7 @@

<script lang="ts">
import type { Session } from '@/js/types';
import { hideAllPoppers } from 'floating-vue';
interface AgentDropdownOption {
label: string;
Expand Down Expand Up @@ -209,6 +212,10 @@ export default {
(option) => option.value.resource.object_id === agent.resource.object_id,
) || null;
},
hideAllPoppers() {
hideAllPoppers();
},
},
};
</script>
Expand Down

0 comments on commit 997076a

Please sign in to comment.