Browse Source

Merge pull request #3095 from nocodb/chore/project-menu-fix

feat(gui-v2): close dropdown menu on esc keydown
pull/3101/head
Raju Udava 2 years ago committed by GitHub
parent
commit
8c6d40ecb4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 20
      packages/nc-gui-v2/pages/nc/[projectId]/index.vue

20
packages/nc-gui-v2/pages/nc/[projectId]/index.vue

@ -1,5 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
import { navigateTo, provideSidebar, ref, useProject, useRoute, useSidebar, useTabs, useUIPermission } from '#imports' import { navigateTo, onKeyStroke, provideSidebar, ref, useProject, useRoute, useTabs, useUIPermission } from '#imports'
import { TabType } from '~/composables' import { TabType } from '~/composables'
import { openLink } from '~/utils' import { openLink } from '~/utils'
@ -11,9 +11,6 @@ const { addTab, clearTabs } = useTabs()
const { isUIAllowed } = useUIPermission() const { isUIAllowed } = useUIPermission()
// set old sidebar state
useSidebar({ isOpen: true })
// create a new sidebar state // create a new sidebar state
const { isOpen, toggle } = provideSidebar({ isOpen: true }) const { isOpen, toggle } = provideSidebar({ isOpen: true })
@ -21,6 +18,16 @@ const dialogOpen = ref(false)
const openDialogKey = ref<string>() const openDialogKey = ref<string>()
const dropdownOpen = ref(false)
onKeyStroke(
'Escape',
() => {
dropdownOpen.value = false
},
{ eventName: 'keydown' },
)
clearTabs() clearTabs()
if (!route.params.type) { if (!route.params.type) {
@ -58,7 +65,7 @@ await loadTables()
<img alt="NocoDB" src="~/assets/img/icons/512x512-trans.png" /> <img alt="NocoDB" src="~/assets/img/icons/512x512-trans.png" />
</div> </div>
<a-dropdown :trigger="['click']"> <a-dropdown v-model:visible="dropdownOpen" :trigger="['click']">
<div <div
:style="{ width: isOpen ? 'calc(100% - 40px) pr-2' : '100%' }" :style="{ width: isOpen ? 'calc(100% - 40px) pr-2' : '100%' }"
:class="[isOpen ? '' : 'justify-center']" :class="[isOpen ? '' : 'justify-center']"
@ -85,9 +92,12 @@ await loadTables()
<div class="flex flex-col"> <div class="flex flex-col">
<div class="text-lg group-hover:(!text-primary) font-semibold truncate">{{ project.title }}</div> <div class="text-lg group-hover:(!text-primary) font-semibold truncate">{{ project.title }}</div>
<div class="flex items-center gap-1">
<div class="group-hover:(!text-primary)">ID:</div>
<div class="text-xs group-hover:text-pink-500 truncate font-italic">{{ project.id }}</div> <div class="text-xs group-hover:text-pink-500 truncate font-italic">{{ project.id }}</div>
</div> </div>
</div> </div>
</div>
</template> </template>
<a-menu-item key="copy"> <a-menu-item key="copy">

Loading…
Cancel
Save