mirror of
https://github.com/psychopy/psychojs.git
synced 2025-05-10 10:40:54 +00:00
GUI._onKeyChange now properly handles dropdown boxes
Now use a Map to keep track of individual elements to prevent duplication. Previously would increment continuously just by switching dropdown options. So users could bypass the requirement to complete starred(*) fields by toggling a dropdown a few times, or by focussing and unfocussing input elements, causing nbSetRequiredKeys++ to increment without limit.
This commit is contained in:
parent
dd23484cf5
commit
0f9eeb636e
@ -79,7 +79,7 @@ export class GUI
|
||||
this._progressBarMax = 0;
|
||||
this._allResourcesDownloaded = false;
|
||||
this._requiredKeys = [];
|
||||
this._nbSetRequiredKeys = 0;
|
||||
this._setRequiredKeys = new Map();
|
||||
|
||||
|
||||
// prepare PsychoJS component:
|
||||
@ -581,7 +581,7 @@ export class GUI
|
||||
*/
|
||||
_updateOkButtonStatus()
|
||||
{
|
||||
if (this._psychoJS.getEnvironment() === ExperimentHandler.Environment.LOCAL || (this._allResourcesDownloaded && this._nbSetRequiredKeys >= this._requiredKeys.length) )
|
||||
if (this._psychoJS.getEnvironment() === ExperimentHandler.Environment.LOCAL || (this._allResourcesDownloaded && this._setRequiredKeys.size >= this._requiredKeys.length) )
|
||||
{
|
||||
$("#buttonOk").button("option", "disabled", false);
|
||||
} else
|
||||
@ -656,9 +656,9 @@ export class GUI
|
||||
const value = element.value;
|
||||
|
||||
if (typeof value !== 'undefined' && value.length > 0)
|
||||
gui._nbSetRequiredKeys++;
|
||||
gui._setRequiredKeys.set(event.target, true);
|
||||
else
|
||||
gui._nbSetRequiredKeys--;
|
||||
gui._setRequiredKeys.delete(event.target);
|
||||
|
||||
gui._updateOkButtonStatus();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user