From 5c4fe1b07a28c21ee39f49c2e0f43880cad19495 Mon Sep 17 00:00:00 2001 From: Adam Obuchowicz Date: Tue, 17 Sep 2024 15:07:06 +0200 Subject: [PATCH] Allow numbers starting with dot in WidgetNumber (#11108) [Screencast from 2024-09-17 13-20-40.webm](https://github.com/user-attachments/assets/561adebb-7d93-4939-9dde-5453d5f304be) (cherry picked from commit 5725e2427d21aab11ddb7c32f171628ee8008b2b) --- CHANGELOG.md | 2 ++ app/gui2/src/components/widgets/NumericInputWidget.vue | 2 ++ 2 files changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index bf2c2c2821..ce08f95814 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ - [Fixed files associations not properly registered on Windows][11030] - [Fixed "rename project" button being broken after not changing project name][11103] +- [Numbers starting with dot (`.5`) are accepted in Numeric Widget][11108] [10774]: https://github.com/enso-org/enso/pull/10774 [10814]: https://github.com/enso-org/enso/pull/10814 @@ -31,6 +32,7 @@ [11014]: https://github.com/enso-org/enso/pull/11014 [11030]: https://github.com/enso-org/enso/pull/11030 [11103]: https://github.com/enso-org/enso/pull/11103 +[11108]: https://github.com/enso-org/enso/pull/11108 #### Enso Standard Library diff --git a/app/gui2/src/components/widgets/NumericInputWidget.vue b/app/gui2/src/components/widgets/NumericInputWidget.vue index 82abc9cac4..9d71ce65cc 100644 --- a/app/gui2/src/components/widgets/NumericInputWidget.vue +++ b/app/gui2/src/components/widgets/NumericInputWidget.vue @@ -28,6 +28,8 @@ const lastValidValue = ref() watch(editedValue, (newValue) => { if (newValue == '' || isNumericLiteral(newValue)) { lastValidValue.value = newValue + } else if (isNumericLiteral('0' + newValue)) { + lastValidValue.value = '0' + newValue } }) const valueString = computed(() => (props.modelValue != null ? props.modelValue.toString() : ''))