From d121803fb90a00b48a82153b5d9ad45f833f7188 Mon Sep 17 00:00:00 2001 From: orlinmalkja Date: Mon, 28 Oct 2024 14:28:04 +0100 Subject: [PATCH 1/3] fix: change the highlight of the target only if target is not null --- src/stores/annotations.ts | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/stores/annotations.ts b/src/stores/annotations.ts index 33d75aae..3ec64c5e 100644 --- a/src/stores/annotations.ts +++ b/src/stores/annotations.ts @@ -229,21 +229,23 @@ export const useAnnotationsStore = defineStore('annotations', () => { annotationStore.setActiveAnnotations(activeAnnotationsList) const selector = AnnotationUtils.generateTargetSelector(removeAnnotation); + const textEl = document.querySelector('#text-content') + const target = textEl.querySelector(selector) - if (selector) { - if (AnnotationUtils.isVariant(removeAnnotation)) { - if (AnnotationUtils.getCurrentLevel(document.querySelector(selector)) > 0 - && Object.keys(activeAnnotations.value).findIndex(key => { - const sel = AnnotationUtils.generateTargetSelector(activeAnnotations.value[key]) - return sel === selector - }) === -1) { - AnnotationUtils.highlightTargets(selector, {operation: 'DEC'}); - } - removeVariantAnnotation(selector, removeAnnotation); - } else { + if (!target) return + + if (AnnotationUtils.isVariant(removeAnnotation)) { + if (AnnotationUtils.getCurrentLevel(document.querySelector(selector)) > 0 + && Object.keys(activeAnnotations.value).findIndex(key => { + const sel = AnnotationUtils.generateTargetSelector(activeAnnotations.value[key]) + return sel === selector + }) === -1) { AnnotationUtils.highlightTargets(selector, {operation: 'DEC'}); - removeSimpleAnnotation(removeAnnotation); } + removeVariantAnnotation(selector, removeAnnotation); + } else { + AnnotationUtils.highlightTargets(selector, {operation: 'DEC'}); + removeSimpleAnnotation(removeAnnotation); } }; From 55a04d3485bbaa2d61167ae24426e256a8c7a953 Mon Sep 17 00:00:00 2001 From: orlinmalkja Date: Mon, 28 Oct 2024 14:47:28 +0100 Subject: [PATCH 2/3] test: show the content of the new item after clicking a few variants at one item and switching to another item --- tests/cypress/e2e/variants.cy.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/cypress/e2e/variants.cy.js b/tests/cypress/e2e/variants.cy.js index 14769860..226ae181 100644 --- a/tests/cypress/e2e/variants.cy.js +++ b/tests/cypress/e2e/variants.cy.js @@ -97,6 +97,32 @@ const selectors = { .should('have.length', 11) }) + it('Should switch normally to the new item when first selecting a few annotations and then switching the item', () => { + // show the annotation content of the new item + cy + .get(selectors.list) + .children() + .eq(0) + .click() + .next() + .click() + .get(selectors.panel1) + .find('ul[role="tree"]') + .find('ul[role="group"]') + .find('div').contains('182b') + .click() + .checkNoAnnotationsAvailable() + + // show the text content of the new item + .get('#text-content') + .find('div') + .should('have.class', 'body karshuni') + .find('div[id="MD12675N1l4l2l6l4l4"]') + .children() + .eq(0) + .should('have.class', 'hi red') + }) + it('select (unselect) a variant item', () => { // should select a variant item and add its witness after the highlighted text + the highlighted text should become light blue cy From b37c6573d32e22a9fc8ad9788b2b2a9ec6138239 Mon Sep 17 00:00:00 2001 From: orlinmalkja Date: Mon, 28 Oct 2024 15:02:43 +0100 Subject: [PATCH 3/3] test: use selectors.panel3 to select the third panel --- tests/cypress/e2e/variants.cy.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/cypress/e2e/variants.cy.js b/tests/cypress/e2e/variants.cy.js index 226ae181..278063ce 100644 --- a/tests/cypress/e2e/variants.cy.js +++ b/tests/cypress/e2e/variants.cy.js @@ -114,9 +114,8 @@ const selectors = { .checkNoAnnotationsAvailable() // show the text content of the new item - .get('#text-content') - .find('div') - .should('have.class', 'body karshuni') + .get(selectors.panel3) + .find('div[class="body karshuni"]') .find('div[id="MD12675N1l4l2l6l4l4"]') .children() .eq(0)