Browse Source

fix: Added back keyboard to formula options

pull/7281/head
Muhammed Mustafa 9 months ago
parent
commit
2f6da8b0d9
  1. 22
      packages/nc-gui/components/smartsheet/column/FormulaOptions.vue

22
packages/nc-gui/components/smartsheet/column/FormulaOptions.vue

@ -99,8 +99,6 @@ const variableListRef = ref<(typeof AntListItem)[]>([])
const sugOptionsRef = ref<(typeof AntListItem)[]>([]) const sugOptionsRef = ref<(typeof AntListItem)[]>([])
const varOptionsRef = ref<(typeof AntListItem)[]>([])
const wordToComplete = ref<string | undefined>('') const wordToComplete = ref<string | undefined>('')
const selected = ref(0) const selected = ref(0)
@ -222,6 +220,7 @@ function selectText() {
} }
function suggestionListUp() { function suggestionListUp() {
console.log('suggestionListUp', suggestion.value)
if (suggestion.value) { if (suggestion.value) {
selected.value = --selected.value > -1 ? selected.value : suggestion.value.length - 1 selected.value = --selected.value > -1 ? selected.value : suggestion.value.length - 1
scrollToSelectedOption() scrollToSelectedOption()
@ -238,10 +237,11 @@ function suggestionListDown() {
function scrollToSelectedOption() { function scrollToSelectedOption() {
nextTick(() => { nextTick(() => {
if (sugOptionsRef.value[selected.value]) { if (sugOptionsRef.value[selected.value]) {
console.log('scrollToSelectedOption', selected.value, sugOptionsRef.value[selected.value].$el, sugListRef.value)
try { try {
sugListRef.value.$el.scrollTo({ sugOptionsRef.value[selected.value].$el.scrollIntoView({
top: sugOptionsRef.value[selected.value].$el.offsetTop, block: 'nearest',
behavior: 'smooth', inline: 'start',
}) })
} catch (e) {} } catch (e) {}
} }
@ -340,7 +340,10 @@ onMounted(() => {
sugOptionsRef[index] = el sugOptionsRef[index] = el
} }
" "
class="cursor-pointer" class="cursor-pointer !overflow-hidden"
:class="{
'bg-gray-100': selected === index,
}"
@click.prevent.stop="appendText(item)" @click.prevent.stop="appendText(item)"
@mouseenter="suggestionPreviewed = item" @mouseenter="suggestionPreviewed = item"
> >
@ -368,15 +371,18 @@ onMounted(() => {
ref="variableListRef" ref="variableListRef"
:data-source="variableList" :data-source="variableList"
:locale="{ emptyText: $t('msg.formula.noSuggestedFormulaFound') }" :locale="{ emptyText: $t('msg.formula.noSuggestedFormulaFound') }"
class="border-1 border-t-0 rounded-b-lg" class="border-1 border-t-0 rounded-b-lg !overflow-hidden"
> >
<template #renderItem="{ item, index }"> <template #renderItem="{ item, index }">
<a-list-item <a-list-item
:ref=" :ref="
(el) => { (el) => {
varOptionsRef[index] = el sugOptionsRef[index + suggestedFormulas.length] = el
} }
" "
:class="{
'bg-gray-100': selected === index + suggestedFormulas.length,
}"
class="cursor-pointer" class="cursor-pointer"
@click.prevent.stop="appendText(item)" @click.prevent.stop="appendText(item)"
> >

Loading…
Cancel
Save