Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setting a number value now renders a real number input #2091

Merged
merged 10 commits into from
Sep 2, 2023
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ The icons may not be reused in other projects without the proper flaticon licens
-->

## Changelog
### **WORK IN PROGRESS**
* (foxriver76) fixed problem with discovery dialog

### 6.9.2 (2023-09-01)
* (foxriver76) show info, if server time differs from client time
* (foxriver76) remove confusion with different names for state (datapoint and state)
Expand Down
19 changes: 19 additions & 0 deletions src/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,23 @@ module.exports = {
'no-alert': 'off',
'class-methods-use-this': 'off',
},
overrides: [
{
files: [
'*.tsx',
],
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
},
rules: {
'@typescript-eslint/no-explicit-any': 'off',
},
},
],
};
1 change: 1 addition & 0 deletions src/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ import InstancesWorker from './Workers/InstancesWorker';
import HostsWorker from './Workers/HostsWorker';
import AdaptersWorker from './Workers/AdaptersWorker';
import ObjectsWorker from './Workers/ObjectsWorker';
// eslint-disable-next-line import/no-unresolved
import DiscoveryDialog from './dialogs/DiscoveryDialog';
import SlowConnectionWarningDialog from './dialogs/SlowConnectionWarningDialog';
import IsVisible from './components/IsVisible';
Expand Down
19 changes: 16 additions & 3 deletions src/src/components/Object/ObjectBrowserValue.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ class ObjectBrowserValue extends Component {

this.inputRef = React.createRef();

this.chartFrom = Date.now() - 3600000 * 2;
this.chartFrom = Date.now() - 3_600_000 * 2;
}

componentDidMount() {
Expand All @@ -203,10 +203,21 @@ class ObjectBrowserValue extends Component {
}

setTimeout(() => {
if (this.inputRef && this.inputRef.current) {
if (this.inputRef?.current) {
const el = this.inputRef.current;
const value = el.value || '';
const origType = el.type;

// type number cannot be selected, so we perform a short workaround
if (el.type === 'number') {
el.type = 'text';
}

el.setSelectionRange(0, value.length);

if (origType === 'number') {
el.type = origType;
}
}
}, 200);
}
Expand Down Expand Up @@ -534,11 +545,13 @@ class ObjectBrowserValue extends Component {
variant="standard"
classes={{ root: this.props.classes.textInput }}
autoFocus
type="number"
inputProps={{ step: this.props.object.common.step, min: this.props.object.common.min, max: this.props.object.common.max }}
inputRef={this.inputRef}
helperText={this.props.t(
'Press ENTER to write the value, when focused',
)}
value={parseFloat(this.state.targetValue) || 0}
value={this.state.targetValue || 0}
label={this.props.t('Value')}
onKeyUp={e => e.keyCode === 13 && this.onUpdate(e)}
onChange={e => this.setState({ targetValue: e.target.value })}
Expand Down
Loading