Author: richardg_uk
Description:
Special:Preferences validation on enwiki is preventing saving new or existing preferences where the watchlist duration is a non-integer number of days.
In [[Special:Preferences#mw-prefsection-watchlist]] the wpwatchlistdays input element has the attribute type="number", ensuring client-side validation that the number of days is numeric.
But the step="..." attribute is not set. For type="number", W3C standards treat a missing step as implying a step value of 1, so non-integers are rejected.[note 1][note 2]
But wpwatchlistdays has previously permitted any positive decimal number (up to prefs-watchlist-days-max). For example, a user could have a valid value of 0.5, which would show changes within the previous 12 hours.
In addition to preventing new non-integer values from being set, this excessive validation prevents the saving of ANY changes to user preferences if there is an existing non-integer value previously saved.
Worse still, on Chrome, when the validation fails, the mw-prefsection-watchlist tab is not activated if it is not already showing. So someone with an existing non-integer wpwatchlistdays setting who is attempting to save unrelated changes to a different prefsection will see no hint as to why their preferences are not saved. (In Chrome Developer Tools, a JavaScript console message states: "An invalid form control with name='wpwatchlistdays' is not focusable." But this is not visible to most users.)
This bug might have arisen now as a result of client-side validation being activated by the switch to HTML5.
I'm experiencing this using Chrome 22.0.1229.79 and a pre-existing prefs-watchlist-days user preference of "0.25" (i.e. 6 hours).
The simplest fix would be to add an additional attribute to the input element to override the default:
step="any"
It might also be appropriate to specify min and max attributes, but these will be caught by server-side validation so their absence is not problematic.
[note 1] http://dev.w3.org/html5/spec/states-of-the-type-attribute.html#number-state-(type=number) "The default step is 1"
[note 2] http://dev.w3.org/html5/spec/common-input-element-attributes.html#concept-input-step-default "If the attribute is absent, then the allowed value step is the default step multiplied by the step scale factor. Otherwise, if the attribute's value is an ASCII case-insensitive match for the string "any", then there is no allowed value step."
Version: unspecified
Severity: major