PMunch / nim-playground-frontend

The front-end for https://play.nim-lang.org
45 stars 16 forks source link

Font size input field is highlighted in red by default, showing that its value is invalid #14

Closed roryokane closed 4 years ago

roryokane commented 4 years ago

Problem

When I load https://play.nim-lang.org/ in Firefox, the “Font size” input field is shown in red:

settings with “Font size” field in red

Hovering over the field reveals a tooltip saying “Please select a valid value.”:

“Font size” error tooltip starting with “Please select a valid value.”

In Google Chrome, I don’t see the red highlight, but I still see the tooltip:

the field and its tooltip in Chrome

The red highlight and the tooltip are a distraction from the user’s main task of trying out Nim code.

Solution

The form should be initialized in a valid state so that the “Font size” text field looks and acts normal.

The validation happens because of the step attribute of that input element:

<input id="fontsize" type="number" min="8" max="50" step="2" required="required">

That input field is defined on line 250 in frontend.nim.

I suggest one of the following fixes:

Note that adding novalidate to the input’s surrounding form element will not disable this validation – novalidate only affects validation upon submitting the form, not displayed errors.

PMunch commented 4 years ago

The step="2" was done because I didn't feel anyone would need that fine control. But I'm fine with either of the changes you proposed, please create a PR to fix it :)