From 757c33bf86db278cb74655af9f60963be29113af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D5=A1=C9=A8=D5=BC=C9=A2=D3=84=D5=A1=D6=85=D5=BC=C9=A2?= Date: Fri, 9 Feb 2024 00:57:45 +0800 Subject: [PATCH] fix(nc-gui): fail to trigger submitCurrency in firefox --- packages/nc-gui/components/cell/Currency.vue | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/packages/nc-gui/components/cell/Currency.vue b/packages/nc-gui/components/cell/Currency.vue index 8a4fc1080b..646f147b87 100644 --- a/packages/nc-gui/components/cell/Currency.vue +++ b/packages/nc-gui/components/cell/Currency.vue @@ -83,6 +83,20 @@ const submitCurrency = () => { editEnabled.value = false } +const onBlur = () => { + // triggered by events like forcus-out / pressing enter + // for non-firefox browsers only + submitCurrency() +} + +const onKeydownEnter = () => { + // for firefox, onBlur is never executed + // we use keydown.enter to trigger submitCurrency + if (/Firefox/.test(navigator.userAgent)) { + submitCurrency() + } +} + onMounted(() => { lastSaved.value = vModel.value }) @@ -96,7 +110,8 @@ onMounted(() => { type="number" class="nc-cell-field w-full h-full text-sm border-none rounded-md py-1 outline-none focus:outline-none focus:ring-0" :placeholder="isEditColumn ? $t('labels.optional') : ''" - @blur="submitCurrency" + @blur="onBlur" + @keydown.enter="onKeydownEnter" @keydown.down.stop @keydown.left.stop @keydown.right.stop