Skip to content

iD Edit mode, start_date and end_date not filled in if just years, expects yyyy-MM-dd #280

Closed

Description

@gregallensworth

Bug description

What is happening?

When I try to edit a feature in iD, a feature with a start_date and/or end_date which are just years, the Start Date and End Date boxes do not get filled in. Instead, I see console messages such as The specified value "1861" does not conform to the required format, "yyyy-MM-dd".

What should be happening?

The Start Date and End Date boxes should be filled in so the dates could be edited. But, how to accept only a year into a yyyy-MM-dd box?

Repro Steps
Please provide detailed instructions to reproduce the behavior:

  1. Go to Edit
  2. Open your debugger
  3. Select / find / click on any feature which has only a partial date
  4. See that the Start Date and End Date are not filled in
  5. See that there is a console message about the year not being a properly-formatted ISO date

By contrast:

  1. Click a feature which has full ISO dates
  2. See that the Start Date and End Date are filled in
  3. See that there are no console messages complaining about the date format

Screenshots & URL

image

The Occidental Hotel and the Hotel Seattle are both visible at https://openhistoricalmap.org/edit#map=20/47.60191/-122.33342 and both have only years.

The block of buildings to the west all/mostly have full dates, and fill in properly.

The Yasler Residence in the middle, has a full End Date and no Start Date. The End Date fills in properly, while the Start Date is left blank which does not result in an error message.

Activity

  1. gregallensworth commented on Aug 25, 2021

    @gregallensworth
    Author

    Option: Expanding the dates client-side

    When a feature is being loaded for editing, perhaps the start_date and end_date could be altered if they are partial?

    The values could be padded out with -01-01 for the Start Date and -12-31 for the End Date.

    Problem: This essentially means altering data when one hits Save. The given date was "1961" and we alter it to "1961-01-01" on save. One could view this as "fixing" the dates so the UI works, or one could view it as "falsifying" the dates since the month & day are filled in by the computer without real research or approval.

  2. gregallensworth commented on Aug 25, 2021

    @gregallensworth
    Author

    Option: Expanding the dates server-side

    There exist for PostgreSQL a date-expansion function, which will pad out "1861" to "1861-01-01" or to "1861-12-31" as needed. https://github.com/OpenHistoricalMap/DateFunctions-plpgsql#varchar-pad_datedatelikestring-varchar-startend-varchar--start

    For editing view, vector data and attributes come from the OSM API, not vector tiles. Perhaps this API could be configured to use pad_date() for these two fields?

    https://openhistoricalmap.org/api/0.6/map?bbox=-122.3382568359375,47.59875528481799,-122.332763671875,47.60245929546311

    <way id="198099635">
      <tag k="name" v="Occidental Hotel"/>
      <tag k="end_date" v="1883"/>
      <tag k="start_date" v="1861"/>
      (irrelevant content trimmed)
    </way>
    

    Same problem as client-side, though: This essentially means altering data. If "1861" is sent out as "1861-01-01" then that's what would go into the editor and be saved back.

    Given that, it still may be a lighter solution if it's the case that tag attributes can be redefined easily, and to include SQL functions.

  3. jeffreyameyer commented on Aug 25, 2021

    @jeffreyameyer
    Member

    This is on ID, right?

    I have no real issue with padding out the MM-DD on non-specified dates, as long as we add something like:
    fixme=start_date, end_date

    or even

    fixme.start_date = yes
    fixme.end_date = yes

    or start_date = machine padded

    etc.

    Just some trail of the machine default, so we can find it later.
    i.e. altering is fine, as long as we make note of it.

    Make sense?

    Good catch, too... this has always bothered me...

  4. changed the title [-]Edit mode, start_date and end_date not filled in if just years, expects yyyy-MM-dd[/-] [+]iD Edit mode, start_date and end_date not filled in if just years, expects yyyy-MM-dd[/+] on Aug 25, 2021
  5. danrademacher commented on Aug 25, 2021

    @danrademacher

    One thing I always liked about “fixing” those dates server-side and only in vtiles, is that in my opinion saying something started in “1623" is not necessarily wrong, it’s just at a one year resolution. As it happens, the timeslider can operate only on complete dates, so we need to pad those out to work in the vector tiles, but in many other cases, a single-year resolution might be just fine. And someday we have to circle back to and deal with things like gothic cathedrals, which took decades to build so in those cases an accurate start date might be even more complex and less precise than a single year, much less a full date. Even if we have to ultimately make assumptions and convert those into YYYY-MM-DD on the backend to work in timeslider, I think the less we modify user-entered data the better.

    In that case, I think what we'd want to do here is relax the validation rules in iD and allow both YYYY and YYYY-MM entries as valid.

  6. gregallensworth commented on Aug 25, 2021

    @gregallensworth
    Author

    Replying to #280 (comment)

    relax the validation rules in iD and allow both YYYY and YYYY-MM entries as valid

    They're input type="date" fields, which do not allow for that. Instead, we would need to change them to plain text fields then write some custom validation mechanism to ensure that the text string is date-like...

  7. danrademacher commented on Aug 25, 2021

    @danrademacher

    Got it. Well, given that #15 is going to come up eventually, and has been intermittently brought up by users as important, it seems like only a matter of time (hah!) before we have to drop an ISO format date input and come up with something more appropriate to the huge variations in time scales and precision in the OHM world.

    Seems like we'd want to take an approach where we match inputs against an array of patterns, to which we can add future acceptable variants as we expand the formats we can accept and convert for timeslider compatibility. For now, that would be just three variants (I think): YYYY, YYYY-MM, and YYYY-MM-DD

  8. gregallensworth commented on Aug 25, 2021

    @gregallensworth
    Author

    have to drop an ISO format date input
    match inputs against an array of patterns
    three variants (I think): YYYY, YYYY-MM, and YYYY-MM-DD

    Okay, so change to text inputs and add custom validation code.

    • change start_date and end_date inputs to text fields

    • add a custom validation to enforce one of those three patterns

      • YYYY
      • YYYY-MM
      • YYYY-MM-DD
      • test with negative years too
  9. danrademacher commented on Aug 25, 2021

    @danrademacher

    Does this have any implications for the date filtering in iD? I forgot how those comparisons are working and we we're approximating the decimal date for that filtering similar to what we are doing for the vector tiles

  10. added 2 commits that reference this issue on Aug 25, 2021
  11. 1 remaining item

  12. danrademacher commented on Sep 1, 2021

    @danrademacher

    Here's a screencast of that flow:
    https://recordit.co/gafDosl5ze

    Note that the final save doesn't fully complete since I'm just running ID locally outside of the OHM website structure, but if I do attempt to save immediately after the first point I made, with a failing date, I get an alaert box as intended.

  13. added a commit that references this issue on Sep 3, 2021
  14. gregallensworth commented on Sep 3, 2021

    @gregallensworth
    Author

    A new approach:

    • validation is done on each input field as it is changed (that is, loses focus after having its value changed, or hitting enter after having its value changed)
    • on no-match, an alert is shown, the field is blanked, and the field is focused

    See branch gin-issue280-startenddate_format and PR https://github.com/OpenHistoricalMap/iD/pull/81/files

  15. danrademacher commented on Sep 8, 2021

    @danrademacher

    Hmm, this is now working as expected for me on start_date:
    image

    But not on end_date:
    image

    I looked a bit at the code and markup to see why that might be, but I can't tell. Maybe the select pattern on the end_date is somehow different?

  16. gregallensworth commented on Sep 8, 2021

    @gregallensworth
    Author

    Replying to #280 (comment)

    This is working for me as expected. I get an alert, then the End Date box is cleared and focused.

    Tested in Mac Chrome, Mac Firefox, Mac Safari.

    image

    Can I get additional details and walkthrough? Maybe there is something in the sequence of clicks that I hadn't anticipated, or perhaps it's something browser-specific?

  17. danrademacher commented on Sep 8, 2021

    @danrademacher

    aha, it is working for me as expected in Chrome. I was testing previous in Firefox

  18. gregallensworth commented on Sep 8, 2021

    @gregallensworth
    Author
    • for Gregor, re-test in Firefox for Mac
    • for Gregor, re-test in Firefox for Windows
    • for Gregor, re-test in Safari
  19. gregallensworth commented on Sep 8, 2021

    @gregallensworth
    Author

    I've re-tested in both, but am still seeing it work as expected.

    Can you make it happen again in Firefox?

    If so, when you leave the End Date field in your test (the blur event on the input, is also the change handler and validation trigger), what did you do that caused you to leave the End Date box? Tabbing to a new field, or clicking a new field? Pressing enter in the field? Clicking some button, or another feature on the map?

    Update per chat:

    But still cannot replicate... Maybe something installation specific e.g. a plugin or "stop alerts on this site" behavior that is suppressing alert popups?

    Update re alert blocking ("Don't allow localhost to prompt you again") - Disabling alerts simply causes alert() to be noop, doesn't interrupt the rest of the validation. The text field is still emptied and focused.

    Updated update We found that Dan's Firefox can do this almost at will, while mine will only do it once in a while if I keep fussing at it, changing fields repeatedly and the validation missing maybe 1 in 15 times. Our best guess is that his Firefox is faster or slower than mine (he uses it as his default, has lots of tabs at all times; I do not), so some event handlers are running differently. Bottom line, though, is if I keep fussing at it, I can get it to fail now and then... so that's a start.

  20. gregallensworth commented on Sep 9, 2021

    @gregallensworth
    Author

    After much fussing, I found that tab and shift-tab don't reliably trigger the blur & change events in Firefox. Below is an example where I tabbed out of the field, and only the four "letter" events actually came through.

    Screenshot: Example of letter events but not tab-blur event

    image

    Screenshot: Another example, no shift-tab event the 5th time

    image

    Via Google I see that this is a known issue dating back some time, and reported in relation to several JavaScript libraries, though not particularly recently. Tabbing reliably triggers in Chrome, but in Firefox it sometimes simply doesn't send an event. The usual recommendation is to add keydown events to detect tab and trigger the change handler...

  21. added 2 commits that reference this issue on Sep 9, 2021
  22. gregallensworth commented on Sep 9, 2021

    @gregallensworth
    Author

    All righty! See current version of gin-issue280-startenddate_format branch.

    • adds keydown event handler, if Tab (includes shift-Tab) then triggers change event handler, even on Firefox
    • moved the validation code directly into change() instead of helper function
      • smaller diff footprint
      • needs to potentially reset val as a side effect if altering their data
    • added new feature: integer-looking strings with under 4 digits, are coerced to 4 digits e.g. "345" and "-20" will become "0345" and "-0020" and therefore valid
  23. danrademacher commented on Sep 21, 2021

    @danrademacher

    This was fixed and deployed last week

  24. added theissue type on Mar 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions