From 8ae0b7818b7bae787e5533737eadcfeabe921e22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mose=20M=C3=BCller?= Date: Mon, 30 Oct 2023 14:36:52 +0100 Subject: [PATCH 1/2] feat (frontend): pressing "-" at the beginning of a number component will add a minus sign --- frontend/src/components/NumberComponent.tsx | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/NumberComponent.tsx b/frontend/src/components/NumberComponent.tsx index bdf8002..9a91127 100644 --- a/frontend/src/components/NumberComponent.tsx +++ b/frontend/src/components/NumberComponent.tsx @@ -139,7 +139,9 @@ export const NumberComponent = React.memo((props: NumberComponentProps) => { renderCount.current++; // Set the cursor position after the component re-renders - const inputElement = document.getElementsByName(id)[0] as HTMLInputElement; + const inputElement = document.getElementsByName( + fullAccessPath + )[0] as HTMLInputElement; if (inputElement && cursorPosition !== null) { inputElement.setSelectionRange(cursorPosition, cursorPosition); } @@ -215,6 +217,16 @@ export const NumberComponent = React.memo((props: NumberComponentProps) => { // Select everything when pressing Ctrl + a target.setSelectionRange(0, target.value.length); return; + } else if (key === '-') { + if (selectionStart === 0 && !value.startsWith('-')) { + newValue = '-' + value; + selectionStart++; + } else if (value.startsWith('-') && selectionStart === 1) { + newValue = value.substring(1); // remove minus sign + selectionStart--; + } else { + return; // Ignore "-" pressed in other positions + } } else if (!isNaN(key) && key !== ' ') { // Check if a number key or a decimal point key is pressed ({ value: newValue, selectionStart } = handleNumericKey( From 9ac6e2c56afc145111da9792d6acbb1df81879a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mose=20M=C3=BCller?= Date: Mon, 30 Oct 2023 14:37:25 +0100 Subject: [PATCH 2/2] npm run build --- src/pydase/frontend/asset-manifest.json | 6 +++--- src/pydase/frontend/index.html | 2 +- .../static/js/{main.afebc391.js => main.1d805bdf.js} | 6 +++--- ...afebc391.js.LICENSE.txt => main.1d805bdf.js.LICENSE.txt} | 0 src/pydase/frontend/static/js/main.1d805bdf.js.map | 1 + src/pydase/frontend/static/js/main.afebc391.js.map | 1 - 6 files changed, 8 insertions(+), 8 deletions(-) rename src/pydase/frontend/static/js/{main.afebc391.js => main.1d805bdf.js} (72%) rename src/pydase/frontend/static/js/{main.afebc391.js.LICENSE.txt => main.1d805bdf.js.LICENSE.txt} (100%) create mode 100644 src/pydase/frontend/static/js/main.1d805bdf.js.map delete mode 100644 src/pydase/frontend/static/js/main.afebc391.js.map diff --git a/src/pydase/frontend/asset-manifest.json b/src/pydase/frontend/asset-manifest.json index b263829..087da0f 100644 --- a/src/pydase/frontend/asset-manifest.json +++ b/src/pydase/frontend/asset-manifest.json @@ -1,13 +1,13 @@ { "files": { "main.css": "/static/css/main.c444b055.css", - "main.js": "/static/js/main.afebc391.js", + "main.js": "/static/js/main.1d805bdf.js", "index.html": "/index.html", "main.c444b055.css.map": "/static/css/main.c444b055.css.map", - "main.afebc391.js.map": "/static/js/main.afebc391.js.map" + "main.1d805bdf.js.map": "/static/js/main.1d805bdf.js.map" }, "entrypoints": [ "static/css/main.c444b055.css", - "static/js/main.afebc391.js" + "static/js/main.1d805bdf.js" ] } \ No newline at end of file diff --git a/src/pydase/frontend/index.html b/src/pydase/frontend/index.html index 544c2bb..12fa4df 100644 --- a/src/pydase/frontend/index.html +++ b/src/pydase/frontend/index.html @@ -1 +1 @@ -pydase App
\ No newline at end of file +pydase App
\ No newline at end of file diff --git a/src/pydase/frontend/static/js/main.afebc391.js b/src/pydase/frontend/static/js/main.1d805bdf.js similarity index 72% rename from src/pydase/frontend/static/js/main.afebc391.js rename to src/pydase/frontend/static/js/main.1d805bdf.js index f1910a1..aaa5cfd 100644 --- a/src/pydase/frontend/static/js/main.afebc391.js +++ b/src/pydase/frontend/static/js/main.1d805bdf.js @@ -1,3 +1,3 @@ -/*! For license information please see main.afebc391.js.LICENSE.txt */ -!function(){var e={694:function(e,t){var n;!function(){"use strict";var r={}.hasOwnProperty;function a(){for(var e=[],t=0;t