Skip to content
This repository has been archived by the owner on Jun 12, 2024. It is now read-only.

Commit

Permalink
fixed: loading to the wrong page if the first page contains no dn wid…
Browse files Browse the repository at this point in the history
…get, kobotoolbox#720

temporary duplicate fix that can be reverted later,
  • Loading branch information
MartijnR committed Nov 30, 2023
1 parent bf5e723 commit 20f4b0d
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions public/js/src/module/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,31 @@ import reasons from './reasons';
import settings from './settings';
import gui from './gui';

// Contains fix for https://github.com/OpenClinica/enketo-express-oc/issues/720
// This function should be removed once PR https://github.com/enketo/enketo/pull/1286 is merged
// and published
pageModule.flipToPageContaining = function ($e) {
const e = $e[0];
const closestPage = e.closest('[role="page"]');

if (closestPage) {
this._flipTo(closestPage);
} else if (e.closest('.question')) {
// If $e is a comment question, and it is not inside a group, there will be no closestPage.
const referer = e.querySelector('[data-for]');
const ancestor = e.closest('.or-repeat, form.or');
if (referer && ancestor) {
const linkedQuestion = ancestor.querySelector(
`[name="${referer.dataset.for}"]`
);
if (linkedQuestion) {
this._flipTo(linkedQuestion.closest('[role="page"]'));
}
}
}
this.$toc.parent().find('.pages-toc__overlay').click();
};

/*
* The only thing we want to change in this function for OC,
* is to NOT flip to the next page when a repeat is the same as a page and
Expand Down

0 comments on commit 20f4b0d

Please sign in to comment.