eprints / orcid_support_advance

ORCID Support Advance plugin
1 stars 6 forks source link

Filter Date Picker Bug in Safari? #66

Closed photomedia closed 2 years ago

photomedia commented 2 years ago

It looks to me like there is a bug on Safari in the Date Picker, for filtering import/export by date. It works fine on Chrome, looks like this when you go to Import/Export: Screen Shot 2022-05-03 at 11 10 31 AM

However, in Safari, when you open the page, it pre-selects a date and looks like this: Screen Shot 2022-05-03 at 11 06 38 AM

In addition, when you change the date, it goes back to pre-selecting today's date as soon as you click on "Filter", even though you're filtering on a different date.

On Safari, it is unclear how to "unset" the date. This was a test using Safari version Version 15.4 (15613.1.17.1.13, 15613)

photomedia commented 2 years ago

Looking into this a little further, I see that the cause of this is browser support for the <input type="date"> element rather than a "bug" per se. As a result, there is no "clear" button on Safari, whereas there is on Chrome. The lack of a "clear" button is not the big issue, though, it's the fact that clicking on "Filter" replaces the date with today's date, because I guess it does a reload, and that's a default for the "native" date picker on Safari desktop, unless maybe we can supply a current "value" attribute on reload? I see that the variable is passed in the URL: example: filter_date=2022-06-07, so we should be able to get it and put it as the "value" on load? On chrome and safari (and other browsers) this means that the date will "stick" rather than clear when clicking on "Filter", so it will be more obvious what filter is currently applied?

photomedia commented 2 years ago

I was experimenting a little with this, trying to add the "filter_date" to the import from ORCID screen's "filter by date" UI component. Would it be just a question of changing this line: https://github.com/eprints/orcid_support_advance/blob/9d67f86d05e67b1696eb5050d1ae5db9982033fc/lib/plugins/EPrints/Plugin/Screen/ImportFromOrcid.pm#L333 to: my $date_picker = $xml->create_element( "input", type => "date", name => "filter_date", "aria-label" => "Filter Date", value => $query->param('filter_date') ); ? I'm a little confused about the role of the form and duplicate_form functions?

While experimenting with that, I noticed another issue, in that the filtering by date on the import screen doesn't seem to be working correctly. I reverted any of my changes to make sure it's not something I changed, but it's still not working as expected. Basically, when I filter by date on import screen, the publication date is always incorrectly listed as, 01/01/1970, see screenshot:

Screen Shot 2022-06-30 at 10 42 24 AM

Is that a bug, or is that only happening on my test repository? I'm working on the sandbox. The issue doesn't seem to show up on the Export screen.

photomedia commented 2 years ago

Looks like this commit https://github.com/eprints/orcid_support_advance/commit/9d67f86d05e67b1696eb5050d1ae5db9982033fc introduced a bug on the import screen: when filtering by date on import screen, the publication date is always incorrectly listed as, 01/01/1970

photomedia commented 2 years ago

I also confirm that this works:

Would it be just a question of changing this line: https://github.com/eprints/orcid_support_advance/blob/9d67f86d05e67b1696eb5050d1ae5db9982033fc/lib/plugins/EPrints/Plugin/Screen/ImportFromOrcid.pm#L333 to: my $date_picker = $xml->create_element( "input", type => "date", name => "filter_date", "aria-label" => "Filter Date", value => $query->param('filter_date') );

The currently filtered date is now visible in the date picker after clicking on "filter" (instead of blank on chrome and today's date on Safari). That resolves the very counter-intuitive situation on Safari and improves things on Chrome - seems like a win-win to me. Still no "clear" button on the Safari date picker, but still much better!

wfyson commented 2 years ago

Should hopefully now be fixed with https://github.com/eprints/orcid_support_advance/commit/dd18186aac77f5187971f65be9e9aee69a183e98 - let me know how you get on!

photomedia commented 2 years ago

Perfect, thank you.