fix: NumberComponent cursor position change

This commit is contained in:
Mose Müller 2023-08-02 12:06:22 +02:00
parent 4597dbca99
commit c5bbaad58d
7 changed files with 13 additions and 11 deletions

View File

@ -119,7 +119,9 @@ export const NumberComponent = React.memo((props: NumberComponentProps) => {
}
// Set the cursor position after the component re-renders
const inputElement = document.getElementsByName(name)[0] as HTMLInputElement;
const inputElement = document.getElementsByName(
parent_path.concat(name)
)[0] as HTMLInputElement;
if (inputElement && cursorPosition !== null) {
inputElement.setSelectionRange(cursorPosition, cursorPosition);
}
@ -212,7 +214,7 @@ export const NumberComponent = React.memo((props: NumberComponentProps) => {
};
return (
<div className={'component boolean'} id={parent_path.concat(name)}>
<div className={'number component'} id={parent_path.concat(name)}>
{process.env.NODE_ENV === 'development' && (
<p>Render count: {renderCount.current}</p>
)}
@ -225,7 +227,7 @@ export const NumberComponent = React.memo((props: NumberComponentProps) => {
type="text"
value={inputString}
disabled={readOnly}
name={name}
name={parent_path.concat(name)}
onKeyDown={handleKeyDown}
/>
</InputGroup>

View File

@ -1,13 +1,13 @@
{
"files": {
"main.css": "/static/css/main.4da62354.css",
"main.js": "/static/js/main.134586fc.js",
"main.js": "/static/js/main.7e1debb9.js",
"index.html": "/index.html",
"main.4da62354.css.map": "/static/css/main.4da62354.css.map",
"main.134586fc.js.map": "/static/js/main.134586fc.js.map"
"main.7e1debb9.js.map": "/static/js/main.7e1debb9.js.map"
},
"entrypoints": [
"static/css/main.4da62354.css",
"static/js/main.134586fc.js"
"static/js/main.7e1debb9.js"
]
}

View File

@ -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 pyDataService UI."/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>pyDataService App</title><script defer="defer" src="/static/js/main.134586fc.js"></script><link href="/static/css/main.4da62354.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 pyDataService UI."/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>pyDataService App</title><script defer="defer" src="/static/js/main.7e1debb9.js"></script><link href="/static/css/main.4da62354.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

File diff suppressed because one or more lines are too long