cidgoh / DataHarmonizer

A standardized browser-based spreadsheet editor and validator that can be run offline and locally, and which includes templates for SARS-CoV-2 and Monkeypox sampling data. This project, created by the Centre for Infectious Disease Genomics and One Health (CIDGOH), at Simon Fraser University, is now an open-source collaboration with contributions from the National Microbiome Data Collaborative (NMDC), the LinkML development team, and others.
MIT License
91 stars 23 forks source link

Fix date editor keyboard copy #416

Closed pkalita-lbl closed 7 months ago

pkalita-lbl commented 7 months ago

I believe this is the necessary fix to get keyboard copy and paste working for date/datetime cells. In HT 8.0.0 they introduced a new mechanism to identify which elements are "owned" by HT. Previously, when we were using HT 7.4.x, adding the handsontableInput class was sufficient. Now they use an attribute called data-hot-input. See: https://github.com/handsontable/handsontable/issues/6383. Without this identification the right document-level event listeners aren't attached when those cells are selected prior to copying.

Secondarily I updated the calls to a few HT helper methods to reflect the preferred ones in 13.1.x.

Lastly, unrelated to all of that I removed the erroneous package-lock.json file and updated yarn.lock to reflect the current dependencies. If we want to switch to using npm for this project instead of yarn I have no strong feelings, but we shouldn't mix the two.

kennethbruskiewicz commented 7 months ago

Taking a look.

kennethbruskiewicz commented 7 months ago

I could be wrong but there are no templates in DataHarmonizer right now that take "xsd:datetime" and "xsd:time" as ranges, only "date". That said the copy-paste function did work for me when testing ambr/AMBR's "sample received date" slot, after picking a date in the control.

The edits look good, will merge.

@pkalita-lbl is there anything about how the HOT editors currently work which should also apply to the other editors we maintain in this codebase?

ddooley commented 7 months ago

Thanks Patrick - it works great; and thx Ken for testing. I'll ensure the other cut/paste changes in mpox rename branch dataharmonizer.js are removed.

ddooley commented 7 months ago

Hmm, there may be one lingering problem. When DH loads, do a paste into a date field. Then switch templates. I'm getting something that hopefully is easy to remedy in FlatpickrEditor.js:

Uncaught runtime errors:
×
ERROR
Cannot read properties of undefined (reading 'destroy')
TypeError: Cannot read properties of undefined (reading 'destroy')
    at DateEditor.destroyElements (webpack-internal:///../lib/editors/FlatpickrEditor.js:88:13)
...
pkalita-lbl commented 7 months ago

I could be wrong but there are no templates in DataHarmonizer right now that take "xsd:datetime" and "xsd:time" as ranges, only "date".

No you're right. NMDC uses datetimes though. Since this fix is in the FlatpickrEditor base class it should apply to the date, datetime, and time cell editors.

is there anything about how the HOT editors currently work which should also apply to the other editors we maintain in this codebase?

Not that I'm aware of!

When DH loads, do a paste into a date field. Then switch templates. I'm getting something that hopefully is easy to remedy in FlatpickrEditor.js

Oops, yeah, I see. Sounds like a timing issue between when the HT instance is recreated for the new template and some asynchronous event callbacks get handled on the old editor. Should be straightforward to fix. I'll get a PR in shortly.