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

Fix/expanded record ux #7298

Merged
merged 22 commits into from
Dec 29, 2023
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
e40ed4e
fix: disable input field after Enter key is pressed
rameshmane7218 Dec 25, 2023
e8424af
fix: tab navigation and focus outline issue
rameshmane7218 Dec 25, 2023
ffcf847
fix: number input up-down button should be hidden
rameshmane7218 Dec 25, 2023
4bce0c5
fix: form view double border issue
rameshmane7218 Dec 25, 2023
cba6af4
fix: input field double border issue of shared form
rameshmane7218 Dec 25, 2023
e6a60e9
fix: long/rich text field default value issue in form view
rameshmane7218 Dec 25, 2023
8e7aaf8
fix: field alignment issue in expanded form
rameshmane7218 Dec 26, 2023
e3e3e7d
fix: lint errors
rameshmane7218 Dec 26, 2023
04b55f5
fix: form field alignment issue
rameshmane7218 Dec 26, 2023
5309785
Merge branch 'develop' into fix/expanded-record-ux
rameshmane7218 Dec 27, 2023
9116bb7
fix: comment input focus issue after saving comment
rameshmane7218 Dec 27, 2023
c17860b
fix: checkbox toggle issue on pressing enter key
rameshmane7218 Dec 27, 2023
4f4a071
fix: percent field text select on focus issue
rameshmane7218 Dec 27, 2023
291532a
fix: review changes
rameshmane7218 Dec 27, 2023
42fcaa4
fix: text area exapnd on enter keypress in form
rameshmane7218 Dec 28, 2023
44754e1
fix: tab focus issue in shared form and expanded form
rameshmane7218 Dec 28, 2023
466049f
fix: expanded comment input focus issue
rameshmane7218 Dec 28, 2023
a5fd82d
fix: review changes
rameshmane7218 Dec 28, 2023
d12a187
fix: review changes of select dropdown fields
rameshmane7218 Dec 29, 2023
51954f1
fix: form submit button focus css issue
rameshmane7218 Dec 29, 2023
937ac53
fix: review changes
rameshmane7218 Dec 29, 2023
37ab476
fix: added missing line break
rameshmane7218 Dec 29, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/nc-gui/components/cell/Checkbox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ useSelectedCellKeyupListener(active, (e) => {

<template>
<div
class="flex cursor-pointer w-full h-full items-center focus:outline-transparent"
class="flex cursor-pointer w-full h-full items-center focus:outline-none"
:class="{
'w-full flex-start pl-2': isForm || isGallery || isExpandedFormOpen,
'w-full justify-center': !isForm && !isGallery && !isExpandedFormOpen,
Expand All @@ -97,7 +97,7 @@ useSelectedCellKeyupListener(active, (e) => {
}"
tabindex="0"
@click="onClick(false, $event)"
@keydown.enter.stop="onClick(false, $event)"
@keydown.enter.stop="onClick(true, $event)"
>
<div
class="flex items-center"
Expand Down
34 changes: 31 additions & 3 deletions packages/nc-gui/components/cell/Currency.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
<script setup lang="ts">
import type { VNodeRef } from '@vue/runtime-core'
import { ColumnInj, EditColumnInj, EditModeInj, IsExpandedFormOpenInj, computed, inject, parseProp, useVModel } from '#imports'
import {
ColumnInj,
EditColumnInj,
EditModeInj,
IsExpandedFormOpenInj,
IsFormInj,
computed,
inject,
parseProp,
useVModel,
} from '#imports'

interface Props {
modelValue: number | null | undefined
Expand Down Expand Up @@ -57,7 +67,10 @@ const currency = computed(() => {

const isExpandedFormOpen = inject(IsExpandedFormOpenInj, ref(false))!

const focus: VNodeRef = (el) => !isExpandedFormOpen.value && !isEditColumn.value && (el as HTMLInputElement)?.focus()
const isForm = inject(IsFormInj)!

const focus: VNodeRef = (el) =>
!isExpandedFormOpen.value && !isEditColumn.value && !isForm.value && (el as HTMLInputElement)?.focus()

const submitCurrency = () => {
if (lastSaved.value !== vModel.value) {
Expand All @@ -78,7 +91,8 @@ onMounted(() => {
:ref="focus"
v-model="vModel"
type="number"
class="w-full h-full text-sm border-none rounded-md outline-none focus:outline-transparent focus:ring-0"
class="w-full h-full text-sm border-none rounded-md py-1 outline-none focus:outline-none focus:ring-0"
:class="isExpandedFormOpen ? 'px-2' : 'px-0'"
:placeholder="isEditColumn ? $t('labels.optional') : ''"
@blur="submitCurrency"
@keydown.down.stop
Expand All @@ -99,3 +113,17 @@ onMounted(() => {
<!-- possibly unexpected string / null with showNull == false -->
<span v-else />
</template>

<style lang="scss" scoped>
/* Chrome, Safari, Edge, Opera */
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
-webkit-appearance: none;
margin: 0;
}

/* Firefox */
input[type='number'] {
-moz-appearance: textfield;
}
</style>
9 changes: 6 additions & 3 deletions packages/nc-gui/components/cell/DatePicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
ColumnInj,
EditColumnInj,
EditModeInj,
IsExpandedFormOpenInj,
ReadonlyInj,
computed,
inject,
Expand Down Expand Up @@ -41,6 +42,8 @@ const readOnly = inject(ReadonlyInj, ref(false))

const isEditColumn = inject(EditColumnInj, ref(false))

const isExpandedFormOpen = inject(IsExpandedFormOpenInj, ref(false))

const active = inject(ActiveCellInj, ref(false))

const editable = inject(EditModeInj, ref(false))
Expand Down Expand Up @@ -238,10 +241,10 @@ const clickHandler = () => {
<a-date-picker
v-model:value="localState"
:picker="picker"
tabindex="0"
:tabindex="0"
:bordered="false"
class="!w-full !px-1 !border-none"
:class="{ 'nc-null': modelValue === null && showNull }"
class="!w-full !py-1 !border-none"
:class="{ 'nc-null': modelValue === null && showNull, '!px-2': isExpandedFormOpen, '!px-0': !isExpandedFormOpen }"
:format="dateFormat"
:placeholder="placeholder"
:allow-clear="!readOnly && !localState && !isPk"
Expand Down
7 changes: 5 additions & 2 deletions packages/nc-gui/components/cell/DateTimePicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
CellClickHookInj,
ColumnInj,
EditColumnInj,
IsExpandedFormOpenInj,
ReadonlyInj,
inject,
isDrawerOrModalExist,
Expand Down Expand Up @@ -39,6 +40,8 @@ const { t } = useI18n()

const isEditColumn = inject(EditColumnInj, ref(false))

const isExpandedFormOpen = inject(IsExpandedFormOpenInj, ref(false))

const column = inject(ColumnInj)!

const isDateInvalid = ref(false)
Expand Down Expand Up @@ -293,8 +296,8 @@ const isColDisabled = computed(() => {
:disabled="isColDisabled"
:show-time="true"
:bordered="false"
class="!w-full !px-0 !py-1 !border-none"
:class="{ 'nc-null': modelValue === null && showNull }"
class="!w-full !py-1 !border-none"
:class="{ 'nc-null': modelValue === null && showNull, '!px-2': isExpandedFormOpen, '!px-0': !isExpandedFormOpen }"
:format="dateTimeFormat"
:placeholder="placeholder"
:allow-clear="!readOnly && !localState && !isPk"
Expand Down
10 changes: 7 additions & 3 deletions packages/nc-gui/components/cell/Decimal.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts" setup>
import type { VNodeRef } from '@vue/runtime-core'
import { EditColumnInj, EditModeInj, IsExpandedFormOpenInj, inject, useVModel } from '#imports'
import { EditColumnInj, EditModeInj, IsExpandedFormOpenInj, IsFormInj, inject, useVModel } from '#imports'

interface Props {
// when we set a number, then it is number type
Expand Down Expand Up @@ -63,6 +63,8 @@ const precision = computed(() => {

const isExpandedFormOpen = inject(IsExpandedFormOpenInj, ref(false))!

const isForm = inject(IsFormInj)!

// Handle the arrow keys as its default behavior is to increment/decrement the value
const onKeyDown = (e: any) => {
if (e.key === 'ArrowDown') {
Expand All @@ -80,7 +82,8 @@ const onKeyDown = (e: any) => {
}
}

const focus: VNodeRef = (el) => !isExpandedFormOpen.value && !isEditColumn.value && (el as HTMLInputElement)?.focus()
const focus: VNodeRef = (el) =>
!isExpandedFormOpen.value && !isEditColumn.value && !isForm.value && (el as HTMLInputElement)?.focus()

watch(isExpandedFormOpen, () => {
if (!isExpandedFormOpen.value) {
Expand All @@ -94,7 +97,8 @@ watch(isExpandedFormOpen, () => {
v-if="editEnabled"
:ref="focus"
v-model="vModel"
class="outline-none !py-2 !px-1 border-none rounded-md w-full h-full !text-sm"
class="outline-none py-1 border-none rounded-md w-full h-full !text-sm"
:class="isExpandedFormOpen ? 'px-2' : 'px-0'"
type="number"
:step="precision"
:placeholder="isEditColumn ? $t('labels.optional') : ''"
Expand Down
10 changes: 7 additions & 3 deletions packages/nc-gui/components/cell/Duration.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
EditColumnInj,
EditModeInj,
IsExpandedFormOpenInj,
IsFormInj,
computed,
convertDurationToSeconds,
convertMS2Duration,
Expand Down Expand Up @@ -83,7 +84,10 @@ const submitDuration = () => {

const isExpandedFormOpen = inject(IsExpandedFormOpenInj, ref(false))!

const focus: VNodeRef = (el) => !isExpandedFormOpen.value && !isEditColumn.value && (el as HTMLInputElement)?.focus()
const isForm = inject(IsFormInj)!

const focus: VNodeRef = (el) =>
!isExpandedFormOpen.value && !isEditColumn.value && !isForm.value && (el as HTMLInputElement)?.focus()
</script>

<template>
Expand All @@ -92,8 +96,8 @@ const focus: VNodeRef = (el) => !isExpandedFormOpen.value && !isEditColumn.value
v-if="editEnabled"
:ref="focus"
v-model="localState"
class="w-full !border-none !outline-none p-0"
:class="{ '!px-2 !py-1': editEnabled }"
class="w-full !border-none !outline-none py-1"
:class="isExpandedFormOpen ? 'px-2' : 'px-0'"
:placeholder="durationPlaceholder"
@blur="submitDuration"
@keypress="checkDurationFormat($event)"
Expand Down
9 changes: 7 additions & 2 deletions packages/nc-gui/components/cell/Email.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
EditColumnInj,
EditModeInj,
IsExpandedFormOpenInj,
IsFormInj,
IsSurveyFormInj,
computed,
inject,
Expand Down Expand Up @@ -50,7 +51,10 @@ const validEmail = computed(() => vModel.value && validateEmail(vModel.value))

const isExpandedFormOpen = inject(IsExpandedFormOpenInj, ref(false))!

const focus: VNodeRef = (el) => !isExpandedFormOpen.value && !isEditColumn.value && (el as HTMLInputElement)?.focus()
const isForm = inject(IsFormInj)!

const focus: VNodeRef = (el) =>
!isExpandedFormOpen.value && !isEditColumn.value && !isForm.value && (el as HTMLInputElement)?.focus()

watch(
() => editEnabled.value,
Expand All @@ -70,7 +74,8 @@ watch(
v-if="editEnabled"
:ref="focus"
v-model="vModel"
class="w-full outline-none text-sm px-1 py-2"
class="w-full outline-none text-sm py-1"
:class="isExpandedFormOpen ? 'px-2' : 'px-0'"
:placeholder="isEditColumn ? $t('labels.optional') : ''"
@blur="editEnabled = false"
@keydown.down.stop
Expand Down
7 changes: 5 additions & 2 deletions packages/nc-gui/components/cell/Float.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts" setup>
import type { VNodeRef } from '@vue/runtime-core'
import { EditColumnInj, EditModeInj, IsExpandedFormOpenInj, inject, useVModel } from '#imports'
import { EditColumnInj, EditModeInj, IsExpandedFormOpenInj, IsFormInj, inject, useVModel } from '#imports'

interface Props {
// when we set a number, then it is number type
Expand Down Expand Up @@ -40,7 +40,10 @@ const vModel = computed({

const isExpandedFormOpen = inject(IsExpandedFormOpenInj, ref(false))!

const focus: VNodeRef = (el) => !isExpandedFormOpen.value && !isEditColumn.value && (el as HTMLInputElement)?.focus()
const isForm = inject(IsFormInj)!

const focus: VNodeRef = (el) =>
!isExpandedFormOpen.value && !isEditColumn.value && !isForm.value && (el as HTMLInputElement)?.focus()
</script>

<template>
Expand Down
19 changes: 16 additions & 3 deletions packages/nc-gui/components/cell/GeoData.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts" setup>
import type { GeoLocationType } from 'nocodb-sdk'
import { Modal as AModal, iconMap, latLongToJoinedString, useVModel } from '#imports'
import { Modal as AModal, IsExpandedFormOpenInj, iconMap, latLongToJoinedString, useVModel } from '#imports'

interface Props {
modelValue?: string | null
Expand All @@ -16,6 +16,8 @@ const emits = defineEmits<Emits>()

const vModel = useVModel(props, 'modelValue', emits)

const isExpandedFormOpen = inject(IsExpandedFormOpenInj, ref(false))

const isExpanded = ref(false)

const isLoading = ref(false)
Expand Down Expand Up @@ -86,7 +88,8 @@ const openInOSM = () => {
<a-dropdown :is="isExpanded ? AModal : 'div'" v-model:visible="isExpanded" :trigger="['click']">
<div
v-if="!isLocationSet"
class="group cursor-pointer flex gap-1 items-center mx-auto max-w-64 justify-center active:(ring ring-accent ring-opacity-100) rounded border-1 p-1 shadow-sm hover:(bg-primary bg-opacity-10) dark:(!bg-slate-500)"
class="group cursor-pointer flex gap-1 items-center mx-auto max-w-64 justify-center active:(ring ring-accent ring-opacity-100) rounded border-1 p-1 shadow-sm hover:(bg-primary bg-opacity-10) dark:(!bg-slate-500) my-1"
tabindex="0"
>
<div class="flex items-center gap-2" data-testid="nc-geo-data-set-location-button">
<component
Expand All @@ -98,7 +101,17 @@ const openInOSM = () => {
</div>
</div>
</div>
<div v-else data-testid="nc-geo-data-lat-long-set">{{ latLongStr }}</div>
<div
v-else
data-testid="nc-geo-data-lat-long-set"
tabindex="0"
class="h-full w-full flex items-center py-1 focus-visible:!outline-none focus:!outline-none"
:class="{
'px-2': isExpandedFormOpen,
}"
>
{{ latLongStr }}
</div>
<template #overlay>
<a-form :model="formState" class="flex flex-col w-max-64 border-1 border-gray-200" @finish="handleFinish">
<a-form-item>
Expand Down
13 changes: 7 additions & 6 deletions packages/nc-gui/components/cell/Integer.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup lang="ts">
import type { VNodeRef } from '@vue/runtime-core'
import { EditColumnInj, EditModeInj, IsExpandedFormOpenInj, inject, useVModel } from '#imports'
import { EditColumnInj, EditModeInj, IsExpandedFormOpenInj, IsFormInj, inject, useVModel } from '#imports'

interface Props {
// when we set a number, then it is number type
Expand Down Expand Up @@ -48,7 +48,10 @@ const vModel = computed({

const isExpandedFormOpen = inject(IsExpandedFormOpenInj, ref(false))!

const focus: VNodeRef = (el) => !isExpandedFormOpen.value && !isEditColumn.value && (el as HTMLInputElement)?.focus()
const isForm = inject(IsFormInj)!

const focus: VNodeRef = (el) =>
!isExpandedFormOpen.value && !isEditColumn.value && !isForm.value && (el as HTMLInputElement)?.focus()

function onKeyDown(e: any) {
const cmdOrCtrl = isMac() ? e.metaKey : e.ctrlKey
Expand Down Expand Up @@ -85,11 +88,9 @@ function onKeyDown(e: any) {
v-if="editEnabled"
:ref="focus"
v-model="vModel"
class="outline-none py-2 px-1 border-none w-full h-full text-sm"
class="outline-none py-1 border-none w-full h-full text-sm"
:class="isExpandedFormOpen ? 'px-2' : 'px-0'"
type="number"
:class="{
'pl-2': isExpandedFormOpen,
}"
style="letter-spacing: 0.06rem"
:placeholder="isEditColumn ? $t('labels.optional') : ''"
@blur="editEnabled = false"
Expand Down
9 changes: 8 additions & 1 deletion packages/nc-gui/components/cell/MultiSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
ColumnInj,
EditColumnInj,
EditModeInj,
IsExpandedFormOpenInj,
IsKanbanInj,
ReadonlyInj,
RowHeightInj,
Expand Down Expand Up @@ -63,6 +64,8 @@ const isEditColumn = inject(EditColumnInj, ref(false))

const rowHeight = inject(RowHeightInj, ref(undefined))

const isExpandedFormOpen = inject(IsExpandedFormOpenInj, ref(false))!

const selectedIds = ref<string[]>([])

const aselect = ref<typeof AntSelect>()
Expand Down Expand Up @@ -351,7 +354,11 @@ const onFocus = () => {
</script>

<template>
<div class="nc-multi-select h-full w-full flex items-center" :class="{ 'read-only': readOnly }" @click="toggleMenu">
<div
class="nc-multi-select h-full w-full flex items-center"
:class="{ 'read-only': readOnly, 'px-2': isExpandedFormOpen }"
@click="toggleMenu"
>
<div
v-if="!active"
class="flex flex-wrap"
Expand Down