From 75c1c202a9479347dd607c8b2c16a5ffa87ba8f1 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Sat, 29 Oct 2022 16:20:07 +0530 Subject: [PATCH] feat(gui): ignore unselecting if clicking inside any picker element Signed-off-by: Pranav C --- packages/nc-gui/components/cell/DatePicker.vue | 2 +- packages/nc-gui/components/cell/DateTimePicker.vue | 10 ++++++---- packages/nc-gui/components/cell/Rating.vue | 6 +----- packages/nc-gui/components/cell/TimePicker.vue | 2 +- packages/nc-gui/components/cell/YearPicker.vue | 2 +- packages/nc-gui/components/smartsheet/Grid.vue | 8 +++++++- packages/nc-gui/components/virtual-cell/BelongsTo.vue | 2 +- packages/nc-gui/components/virtual-cell/HasMany.vue | 2 +- packages/nc-gui/components/virtual-cell/ManyToMany.vue | 4 ++-- .../components/virtual-cell/components/ListItems.vue | 1 - 10 files changed, 21 insertions(+), 18 deletions(-) diff --git a/packages/nc-gui/components/cell/DatePicker.vue b/packages/nc-gui/components/cell/DatePicker.vue index f515e0873c..bb082b6f73 100644 --- a/packages/nc-gui/components/cell/DatePicker.vue +++ b/packages/nc-gui/components/cell/DatePicker.vue @@ -81,7 +81,7 @@ useSelectedCellKeyupListener(inject(ActiveCellInj, ref(false)), (e: KeyboardEven :placeholder="placeholder" :allow-clear="!readOnly && !localState && !isPk" :input-read-only="true" - :dropdown-class-name="`${randomClass} nc-picker-date`" + :dropdown-class-name="`${randomClass} nc-picker-date ${open ? 'active' : ''}`" :open="readOnly || (localState && isPk) ? false : open" @click="open = !open" > diff --git a/packages/nc-gui/components/cell/DateTimePicker.vue b/packages/nc-gui/components/cell/DateTimePicker.vue index 5c16909add..3acae997e3 100644 --- a/packages/nc-gui/components/cell/DateTimePicker.vue +++ b/packages/nc-gui/components/cell/DateTimePicker.vue @@ -15,6 +15,8 @@ const { isMysql } = useProject() const readOnly = inject(ReadonlyInj, ref(false)) +const active = inject(ActiveCellInj, ref(false)) + let isDateInvalid = $ref(false) const dateFormat = isMysql ? 'YYYY-MM-DD HH:mm:ss' : 'YYYY-MM-DD HH:mm:ssZ' @@ -57,7 +59,7 @@ watch( { flush: 'post' }, ) -useSelectedCellKeyupListener(inject(ActiveCellInj, ref(false)), (e: KeyboardEvent) => { +useSelectedCellKeyupListener(active, (e: KeyboardEvent) => { switch (e.key) { case 'Enter': e.stopPropagation() @@ -81,10 +83,10 @@ useSelectedCellKeyupListener(inject(ActiveCellInj, ref(false)), (e: KeyboardEven :placeholder="isDateInvalid ? 'Invalid date' : ''" :allow-clear="!readOnly && !localState && !isPk" :input-read-only="true" - :dropdown-class-name="`${randomClass} nc-picker-datetime`" - :open="readOnly || (localState && isPk) ? false : open" + :dropdown-class-name="`${randomClass} nc-picker-datetime ${open ? 'active' : ''}`" + :open="readOnly || (localState && isPk) ? false : open && active" :disabled="readOnly || (localState && isPk)" - @click="open = !open" + @click="open = active && !open" @ok="open = !open" > diff --git a/packages/nc-gui/components/cell/Rating.vue b/packages/nc-gui/components/cell/Rating.vue index 51aadec80d..44308292e6 100644 --- a/packages/nc-gui/components/cell/Rating.vue +++ b/packages/nc-gui/components/cell/Rating.vue @@ -37,11 +37,7 @@ useSelectedCellKeyupListener(inject(ActiveCellInj, ref(false)), (e: KeyboardEven