psychopy.org | Reference | Downloads | Github

Fixes for bugs in PsychoJS libraries

Problem: on the dialog created by DlgFromDict, clicking on the label for the input element does not focus/select the input element

Fix: the [for] property in the label element should use keyId, not key

Change line 149 of https://github.com/psychopy/psychojs/blob/master/js/core/GUI.js

htmlCode += '<label for="' + keyId + '">' + key + '</label>';

Problem: using special characters, such as question mark, in the DlgFromDict dictionary causes problems with keyId selection in jQuery. For example, if you want to ask {"Would you like a slice of cake?*": ["Yes", "No"]} with a dropdown, the question mark will cause problems.

Fix: use $.escapeSelector() to properly escape special characters

Change line 133 of https://github.com/psychopy/psychojs/blob/master/js/core/GUI.js

const keyId = $.escapeSelector(key) + '_id';

Line 203:

const keyId = $.escapeSelector(key) + '_id';

Line 230:

const input = document.getElementById($.escapeSelector(key) + '_id');

Hi,

Thanks, this looks like great work to track down these issues. To get a fix incorporated, it would be best to raise it as an issue on the Github site, as it will likely get lost on this forum:

Since you’ve identified the solution as well as the problem, even better, you could raise a pull request and get credit for your contribution.

See pull request for the the above (and more!) fixes: