davidskalinder / mpeds-coder

MPEDS Annotation Interface
MIT License
0 stars 0 forks source link

Click events are getting assigned to the wrong text-select delete buttons #93

Closed davidskalinder closed 4 years ago

davidskalinder commented 4 years ago

All right, I'm about 95% certain why those click events are getting assigned wrong. Here are the exciting details:

The ID for the HTML element that the click listeners get attached to is a concatenation of the string "del", the variable name, the position of the text, and the timestamp of when that bit of JS runs. Usually the timestamp will be different, but often it's very similar: the last digit (probably like milliseconds or something?) often only differs by one between two different elements; and sometimes by chance it'll be the same for two elements. When the timestamp is the same for duplicate elements, the IDs will be the same, which makes the HTML invalid; so the JS deals with the broken HTML as well as it can, assigning all events to the first instance of the ID.

All of which means that this behavior has probably been happening all along, but should be corrected by whatever we do to fix #89.

I'm going to look to see whether there's an easy short-term fix for this. If not, I vote we just live with it until #89 is fixed.

(EDIT: corrected the issue number)

Originally posted by @davidskalinder in https://github.com/davidskalinder/mpeds-coder/issues/92#issuecomment-642287750

davidskalinder commented 4 years ago

Short version: I don't think this is worth fixing, considering that it's just temporary anyway.

Long version: Fixing this would mean having the controller function query the id field when it looks up the variable info, changing ec.js's call to assemble the elements to pass the ID, putting the ID into the element name in shared.js AND then doing all the same stuff for (at least) all the functionality that handles when new selections are added. That's a lot of places for something to go wrong. So I think we should live with a few weeks of confusion until fixing #89 ensures that the IDs will always be different anyway.

So I'm going to close this (though @olderwoman or others can feel free to reopen or comment if they disagree with this conclusion).