Skip to content

Commit 53decfb

Browse files
committed
RA-2093: Form Navigator: Properly default to first field on a form
1 parent 826ee3d commit 53decfb

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

omod/src/main/webapp/resources/scripts/navigator/navigator.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ formElement.hasClass('allow-empty-form') || formElement.find('htmlform').hasClas
7878
var questionsHandler = QuestionsHandler(questions, prevButton);
7979
var fieldsHandler = FieldsKeyboardHandler(fields, questionsHandler);
8080

81+
// go to the first field by triggering a tab
8182
fieldsHandler.handleTabKey();
8283

8384
$('body').keydown(function(key) {

omod/src/main/webapp/resources/scripts/navigator/navigatorHandlers.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,11 @@ function FieldsKeyboardHandler(fieldModels, questionsHandler) {
6969
}
7070
} else {
7171
if(showFirstFieldIfNoneIsActive) {
72-
questionsHandler.selectedQuestion() || questionsHandler.nextQuestion();
73-
if (questionsHandler.selectedQuestion() && questionsHandler.selectedQuestion().fields && questionsHandler.selectedQuestion().fields.length > 0) {
74-
questionsHandler.selectedQuestion().fields[0].toggleSelection();
72+
// the assumption here is that there is *at least* one field on the form, which should always be the case if there is a confirmation page
73+
while(!questionsHandler.selectedQuestion() || !questionsHandler.selectedQuestion().fields || questionsHandler.selectedQuestion().fields.length === 0) {
74+
questionsHandler.nextQuestion();
7575
}
76+
questionsHandler.selectedQuestion().fields[0].toggleSelection();
7677
return true;
7778
}
7879
}

0 commit comments

Comments
 (0)