diff --git a/examples/gfl.html b/examples/gfl.html index 108a854d..6ead3a19 100644 --- a/examples/gfl.html +++ b/examples/gfl.html @@ -27,139 +27,147 @@ diff --git a/src/store/annotations/actions.js b/src/store/annotations/actions.js index b556e85d..6a1754dc 100644 --- a/src/store/annotations/actions.js +++ b/src/store/annotations/actions.js @@ -25,8 +25,9 @@ export const addActiveAnnotation = ({ getters, rootGetters, dispatch }, id) => { Utils.highlightTargets(selector, { operation: 'INC' }); if (elements.length > 0) { - Utils.addIcon(elements[0], newActiveAnnotation, iconName); - scrollIntoViewIfNeeded(elements[0], document.getElementById('text-content')); + const target = elements[0]; + Utils.addIcon(target, newActiveAnnotation, iconName); + scrollIntoViewIfNeeded(target, target.closest('.panel-body')); // Get the scroll container of Quasar tab panel const annotationsView = document.querySelector('.annotations-view').parentElement.parentElement; diff --git a/tests/cypress/e2e/annotation.cy.js b/tests/cypress/e2e/annotation.cy.js index 01c18657..9a6cd371 100644 --- a/tests/cypress/e2e/annotation.cy.js +++ b/tests/cypress/e2e/annotation.cy.js @@ -11,6 +11,7 @@ describe('Annotation - Multiple Tabs', () => { .get('.panels-target > .item:nth-child(4) .q-tab-panel .q-list .q-item') .should('be.visible'); }); + it('Should display first annotation tab', () => { cy .get('.panels-target > .item:nth-child(4) .q-tabs__content .q-tab') @@ -30,7 +31,7 @@ describe('Annotation - Multiple Tabs', () => { .get('.panels-target > .item:nth-child(4) .q-tabs__content .q-tab') .eq(1) .click() - .wait(400)// wait for tab switch transition + .wait(400) // wait for tab switch transition .should('have.class', 'q-tab--active') .get('.panels-target > .item:nth-child(4) .q-tab-panel .q-list .q-item') .eq(0) @@ -156,4 +157,20 @@ describe('Annotation - Multiple Tabs', () => { .find('#text-content [data-annotation-ids][data-annotation-level="1"]') .should('have.length', 0); }); + + it('Should scroll in text to highlighted annotation', { scrollBehavior: false }, () => { + + // We scroll down the text panel first and select the first annotation + // because there is a problem with initial scrolling of text panel. + // Somehow it works when scroll programmatically like described above. + cy + .get('.panels-target > .item:nth-child(3) .content-view') + .scrollTo('bottom') + .get('.panels-target > .item:nth-child(4)') + .find('.q-tab-panel .q-list .q-item') + .first() + .click() + .get('#t_Mingana_ar_christ_93_84_MD1816225N1l5l3l5l5l47l3l2_1') + .should('be.visible'); + }); });