Page MenuHomePhabricator

Scrolling in the rcdays input field in the preferences leads to decimal value with lots of digits
Closed, DuplicatePublic

Description

Steps to reproduce:

  • Load https://www.mediawiki.org/wiki/Special:Preferences#mw-prefsection-rc
  • Select the input field with the label Days to show in recent changes:
  • -> The input field contains the default value 7.
  • Scroll up one click.
  • -> The input field contains 6.04166666666667.
  • Further scroll ups the value does not change.
  • A scroll down leads to 7.04166666666667.
  • Further scroll downs leads to 8.04166666666667, 9.04166666666667, ... up to the maximum allowed days.

I can only reproduce this behavior in Firefox. On Internet Explorer and on Chrome scrolling in the input fields scrolls the page and does not change the value.
For the input field recent days a value change by scrolling is useless and should be disabled.

Event Timeline

I can reproduce on Google Chrome 70.0 this using the arrow keys, and I can reproduce this on the OOUI Demos page with the NumberInputWidget using the scroll wheel. From what I understand, (I believe it was @matmarex who mentioned it) this is caused by the way JavaScript handles numbers: All numbers in JavaScript are represented as floating point numbers (a double, to be precise). The problem is that floating point calculations are never accurate, and the observed drift is due to small rounding errors that accumulate.

This is more or less T102128: Decimal step on NumberInputWidget results in cumulative binary rounding error. The step value seems to be derived from the minimum and is set to some strange decimal value. Fun fact: On GlobalPreferences this only happens once you go below 1, see T206383: Inputs for numbers use different input widget types on Special:Preferences vs. Special:GlobalPreferences.