mirror of
https://github.com/tiqi-group/pydase.git
synced 2025-06-06 13:30:41 +02:00
Merge pull request #55 from tiqi-group/50-problem-with-negative-number
feat: pressing "-" at the start of a number component toggles the sign
This commit is contained in:
commit
f8495dc949
@ -139,7 +139,9 @@ export const NumberComponent = React.memo((props: NumberComponentProps) => {
|
|||||||
renderCount.current++;
|
renderCount.current++;
|
||||||
|
|
||||||
// Set the cursor position after the component re-renders
|
// 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) {
|
if (inputElement && cursorPosition !== null) {
|
||||||
inputElement.setSelectionRange(cursorPosition, cursorPosition);
|
inputElement.setSelectionRange(cursorPosition, cursorPosition);
|
||||||
}
|
}
|
||||||
@ -215,6 +217,16 @@ export const NumberComponent = React.memo((props: NumberComponentProps) => {
|
|||||||
// Select everything when pressing Ctrl + a
|
// Select everything when pressing Ctrl + a
|
||||||
target.setSelectionRange(0, target.value.length);
|
target.setSelectionRange(0, target.value.length);
|
||||||
return;
|
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 !== ' ') {
|
} else if (!isNaN(key) && key !== ' ') {
|
||||||
// Check if a number key or a decimal point key is pressed
|
// Check if a number key or a decimal point key is pressed
|
||||||
({ value: newValue, selectionStart } = handleNumericKey(
|
({ value: newValue, selectionStart } = handleNumericKey(
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
{
|
{
|
||||||
"files": {
|
"files": {
|
||||||
"main.css": "/static/css/main.c444b055.css",
|
"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",
|
"index.html": "/index.html",
|
||||||
"main.c444b055.css.map": "/static/css/main.c444b055.css.map",
|
"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": [
|
"entrypoints": [
|
||||||
"static/css/main.c444b055.css",
|
"static/css/main.c444b055.css",
|
||||||
"static/js/main.afebc391.js"
|
"static/js/main.1d805bdf.js"
|
||||||
]
|
]
|
||||||
}
|
}
|
@ -1 +1 @@
|
|||||||
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site displaying a pydase UI."/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>pydase App</title><script defer="defer" src="/static/js/main.afebc391.js"></script><link href="/static/css/main.c444b055.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
|
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site displaying a pydase UI."/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>pydase App</title><script defer="defer" src="/static/js/main.1d805bdf.js"></script><link href="/static/css/main.c444b055.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
|
File diff suppressed because one or more lines are too long
1
src/pydase/frontend/static/js/main.1d805bdf.js.map
Normal file
1
src/pydase/frontend/static/js/main.1d805bdf.js.map
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user