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

Number input field doesn't respect step value #643

Closed
pacive opened this issue Dec 15, 2020 · 1 comment · Fixed by #658 or #873
Closed

Number input field doesn't respect step value #643

pacive opened this issue Dec 15, 2020 · 1 comment · Fixed by #658 or #873
Assignees
Labels
bug Something isn't working main ui Main UI

Comments

@pacive
Copy link
Member

pacive commented Dec 15, 2020

The problem

My binding has a need to configure a decimal value with 6 decimals precision, but the input field only allows 2 decimals. After examining the code (not really fluent in js, and not familiar with vue so may have looked in the wrong place), the step parameter in the config-description should be what's decides the precision, otherwise it defaults to step="0.01". I set this to 0.000001, but nothing changes. When I inspect the response to /rest/config-descriptions/{thing-typeUID} however, the parameter is not called step, but stepsize. Might this be what's causing the issue?

Html for the generated input-field:

<input name="latitude" type="number" step="0.01" data-validate="true" class="input-with-value" required="">

Config-description:

	<config-description uri="thing-type:smhi:forecast">
		<parameter name="latitude" type="decimal" step="0.000001" required="true">
			<label>Latitude</label>
			<description>Latitude for the forecast</description>
		</parameter>
...
	</config-description>

Expected behavior

The input field validates according to the step parameter in the config-description.

Steps to reproduce

  1. Install the SMHI-binding
    Note: The binding included in the distribution doesn't include the step parameter in the config-description, so need to be built from the source-code at my github repo
  2. Create a forecast thing
  3. Enter values for longitude or latitude

Your environment

runtimeInfo:
  version: 3.0.0
  buildString: "Build #2067"
locale: en_SE
systemInfo:
  configFolder: C:\Users\ander\AppData\Local\Openhab3\conf
  userdataFolder: C:\Users\ander\AppData\Local\Openhab3\userdata
  logFolder: C:\Users\ander\AppData\Local\Openhab3\userdata\logs
  javaVersion: 11.0.8
  javaVendor: Oracle Corporation
  javaVendorVersion: "18.9"
  osName: Windows 10
  osVersion: "10.0"
  osArchitecture: amd64
  availableProcessors: 8
  freeMemory: 46551096
  totalMemory: 191889408
bindings:
  - smhi
clientInfo:
  device:
    ios: false
    android: false
    androidChrome: false
    desktop: true
    iphone: false
    ipod: false
    ipad: false
    edge: false
    ie: false
    firefox: false
    macos: false
    windows: true
    cordova: false
    phonegap: false
    electron: false
    nwjs: false
    webView: false
    webview: false
    standalone: false
    os: windows
    pixelRatio: 1.25
    prefersColorScheme: light
  isSecureContext: true
  locationbarVisible: true
  menubarVisible: true
  navigator:
    cookieEnabled: true
    deviceMemory: 8
    hardwareConcurrency: 8
    language: en-US
    languages:
      - en-US
      - sv
      - en-GB
      - sv-SE
    onLine: true
    platform: Win32
  screen:
    width: 1536
    height: 864
    colorDepth: 24
  support:
    touch: false
    pointerEvents: true
    observer: true
    passiveListener: true
    gestures: false
    intersectionObserver: true
  themeOptions:
    dark: light
    filled: true
    pageTransitionAnimation: default
    bars: filled
    homeNavbar: default
    homeBackground: default
    expandableCardAnimation: default
  userAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML,
    like Gecko) Chrome/87.0.4280.88 Safari/537.36
timestamp: 2020-12-15T08:51:11.940Z

Browser console

Browser network traffic

Response from /rest/config-descriptions/smhi:forecast (channels omitted):

{"configParameters":[{"description":"Latitude for the forecast","label":"Latitude","name":"latitude","required":true,"type":"DECIMAL","stepsize":0.000001,"readOnly":false,"multiple":false,"advanced":false,"verify":false,"limitToOptions":true,"options":[],"filterCriteria":[]},{"description":"Longitude for the forecast","label":"Longitude","name":"longitude","required":true,"type":"DECIMAL","stepsize":0.000001,"readOnly":false,"multiple":false,"advanced":false,"verify":false,"limitToOptions":true,"options":[],"filterCriteria":[]},{"description":"The hourly forecasts to display","label":"Hourly Forecasts","name":"hourlyForecasts","required":false,"type":"INTEGER","readOnly":false,"multiple":true,"advanced":false,"verify":false,"limitToOptions":true,"options":[{"label":"Current hour","value":"0"},{"label":"Next hour","value":"1"},{"label":"2 hours from now","value":"2"},{"label":"3 hours from now","value":"3"},{"label":"4 hours from now","value":"4"},{"label":"5 hours from now","value":"5"},{"label":"6 hours from now","value":"6"},{"label":"7 hours from now","value":"7"},{"label":"8 hours from now","value":"8"},{"label":"9 hours from now","value":"9"},{"label":"10 hours from now","value":"10"},{"label":"11 hours from now","value":"11"},{"label":"12 hours from now","value":"12"},{"label":"13 hours from now","value":"13"},{"label":"14 hours from now","value":"14"},{"label":"15 hours from now","value":"15"},{"label":"16 hours from now","value":"16"},{"label":"17 hours from now","value":"17"},{"label":"18 hours from now","value":"18"},{"label":"19 hours from now","value":"19"},{"label":"20 hours from now","value":"20"},{"label":"21 hours from now","value":"21"},{"label":"22 hours from now","value":"22"},{"label":"23 hours from now","value":"23"},{"label":"24 hours from now","value":"24"}],"filterCriteria":[]},{"description":"The daily forecasts to display","label":"Daily Forecasts","name":"dailyForecasts","required":false,"type":"INTEGER","readOnly":false,"multiple":true,"advanced":false,"verify":false,"limitToOptions":true,"options":[{"label":"Today","value":"0"},{"label":"Tomorrow","value":"1"},{"label":"2 days from now","value":"2"},{"label":"3 days from now","value":"3"},{"label":"4 days from now","value":"4"},{"label":"5 days from now","value":"5"},{"label":"6 days from now","value":"6"},{"label":"7 days from now","value":"7"},{"label":"8 days from now","value":"8"},{"label":"9 days from now","value":"9"}],"filterCriteria":[]}],"parameterGroups":[],"properties":{},"extensibleChannelTypeIds":[],"UID":"smhi:forecast","label":"SMHI Weather Forecast","description":"Gets weather forecasts from SMHI","listed":true,"supportedBridgeTypeUIDs":[],"bridge":false}

Additional information

@pacive pacive added bug Something isn't working main ui Main UI labels Dec 15, 2020
@ghys ghys self-assigned this Dec 17, 2020
ghys added a commit to ghys/openhab-webui that referenced this issue Dec 17, 2020
Fixes openhab#643.

Signed-off-by: Yannick Schaus <github@schaus.net>
@ghys ghys closed this as completed in #658 Dec 17, 2020
ghys added a commit that referenced this issue Dec 17, 2020
Fixes #643.

Validate numbers on blur only
Allows to input "-" temporarily, fixes #519.
Don't show the clear button (it gets over the stepper arrows on some browsers).

Signed-off-by: Yannick Schaus <github@schaus.net>
@pacive
Copy link
Member Author

pacive commented Jan 27, 2021

After updating my production system to 3.0 I noticed this issue is still present. The thing-type configParameters have stepsize: 0.000001, but the input element still have it set to 0.01.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working main ui Main UI
Projects
None yet
2 participants