Implement the step attribute for <input type=month>

RESOLVED FIXED in Firefox 51

Status

()

Core
DOM: Core & HTML
P2
normal
RESOLVED FIXED
a year ago
11 months ago

People

(Reporter: jessica, Assigned: jessica)

Tracking

Trunk
mozilla51
Points:
---

Firefox Tracking Flags

(firefox50 affected, firefox51 fixed)

Details

Attachments

(1 attachment)

Comment hidden (empty)
Priority: -- → P2
(Assignee)

Comment 1

a year ago
I find our implementation of input type=date's step attribute a little bit confusing when step is not an integer. In our current implementation, we 'round' the step to the LCM of step and the scale factor to avoid a step mismatch. So, for example, if step=0.9, the actual step used 9 days [1], but if step=1.5, the actual step used is 3 days. I think this is not very trivial for users.

I tested Chrome and it seems that they just round the step value, if step=1.2, the actual step used is 1 day, if step=1.5, the actual step used is 2 days.

The spec just says: "When the element is suffering from a step mismatch, the user agent may round the element's value to the nearest date for which the element would not suffer from a step mismatch." [2]


[1] http://hg.mozilla.org/mozilla-central/file/711963e8daa3/dom/html/test/forms/test_step_attribute.html#l204
[2] https://html.spec.whatwg.org/multipage/forms.html#date-state-(type=date)
(Assignee)

Comment 2

a year ago
Olli, may I know your comment about comment 1? Thanks.
Flags: needinfo?(bugs)
(In reply to Jessica Jong [:jessica] from comment #1)
> So, for example, if step=0.9, the actual step used 9 days [1], but
> if step=1.5, the actual step used is 3 days. I think this is not very
> trivial for users.
I don't quite understand how we get these results, but if so, sounds really weird and changing it to be closer to what Chrome does is totally fine.

Bug 769359 doesn't explain why things have been implemented the way they have.
Flags: needinfo?(bugs)
(Assignee)

Comment 4

a year ago
(In reply to Olli Pettay [:smaug] from comment #3)
> (In reply to Jessica Jong [:jessica] from comment #1)
> > So, for example, if step=0.9, the actual step used 9 days [1], but
> > if step=1.5, the actual step used is 3 days. I think this is not very
> > trivial for users.
> I don't quite understand how we get these results, but if so, sounds really
> weird and changing it to be closer to what Chrome does is totally fine.
> 
> Bug 769359 doesn't explain why things have been implemented the way they
> have.

From the comment [1], it says:
      // In case this is a date and the step is not an integer, we don't want to
      // display the dates corresponding to the truncated timestamps of valueLow
      // and valueHigh because they might suffer from a step mismatch as well.
      // Instead we want the timestamps to correspond to a rounded day. That is,
      // we want a multiple of the step scale factor (1 day) as well as of step.

It's not wrong, it's just kind of confusing for users. What Chrome does is simpler, but it implies it does allow non-integer step, cause it's always rounded to an integer.

I'll file a separate bug for type=date step attribute if we are going to change it, type=month scale factor is 1 (month), so I think we won't be having this problem.

[1] http://hg.mozilla.org/mozilla-central/file/feaaf1af1065/dom/html/HTMLInputElement.cpp#l7507
(Assignee)

Updated

a year ago
Assignee: nobody → jjong
(Assignee)

Comment 5

a year ago
Actually, type=month does suffer from the same problem when step is not an integer, so I filed Bug 1289272 and will work on it first.
(Assignee)

Comment 6

a year ago
Created attachment 8777266 [details] [diff] [review]
patch, v1.
Attachment #8777266 - Flags: review?(bugs)

Updated

a year ago
Attachment #8777266 - Flags: review?(bugs) → review+
(Assignee)

Comment 7

a year ago
https://treeherder.mozilla.org/#/jobs?repo=try&revision=57d6acd3dbfc
Keywords: checkin-needed

Comment 8

a year ago
Pushed by cbook@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/4ec3149b367b
Implement the step attribute for <input type=month>. r=smaug
Keywords: checkin-needed

Comment 9

a year ago
bugherder
https://hg.mozilla.org/mozilla-central/rev/4ec3149b367b
Status: NEW → RESOLVED
Last Resolved: a year ago
status-firefox51: --- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla51
Blocks: 1307384
No longer blocks: 1307384
You need to log in before you can comment on or make changes to this bug.