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

Commit

Permalink
fixed: OC: when opening form and automatically going to dn widget on …
Browse files Browse the repository at this point in the history
…an image-map question, the image map ends up in the dn modal(add delay only on image-map) (#445)

#378
  • Loading branch information
theywa authored Mar 5, 2021
1 parent 6a837c1 commit d68d47e
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions widget/discrepancy-note/dn-widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -569,11 +569,13 @@ class Comment extends Widget {
} );

// Scroll directly to Query modal if not enough height for user to view the Query modal
const queryModal = this.linkedQuestion.querySelector( '.widget.or-comment-widget' );
if ( window.innerHeight - this.linkedQuestion.offsetHeight < queryModal.offsetHeight ) {
queryModal.scrollIntoView( { behavior: 'smooth', block: 'start', inline: 'nearest' } );
// https://github.com/OpenClinica/enketo-express-oc/issues/378
if ( this.linkedQuestion.classList.contains( 'or-appearance-image-map' ) ) {
setTimeout( () => {
this._scrollToview();
}, 500);
} else {
this.linkedQuestion.scrollIntoView( { behavior: 'smooth', block: 'start', inline: 'nearest' } );
this._scrollToview();
}

const closeButton = widget.querySelector( '.or-comment-widget__content__btn-close-x' );
Expand All @@ -588,6 +590,16 @@ class Comment extends Widget {

}

_scrollToview() {
const queryModal = this.linkedQuestion.querySelector( '.widget.or-comment-widget' );
const option = { behavior: 'smooth', block: 'start', inline: 'nearest' }
if ( window.innerHeight - this.linkedQuestion.offsetHeight < queryModal.offsetHeight ) {
queryModal.scrollIntoView( option );
} else {
this.linkedQuestion.scrollIntoView( option );
}
}

// switches the right pane of the widget that shows the form (optionally) and the thread content
_switch( event ) {
this.type = event.currentTarget.dataset.type;
Expand Down

0 comments on commit d68d47e

Please sign in to comment.