@empiricalrun/test-gen 0.38.7 → 0.38.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @empiricalrun/test-gen
2
2
 
3
+ ## 0.38.8
4
+
5
+ ### Patch Changes
6
+
7
+ - deb93bd: fix: scroll while annotating
8
+
3
9
  ## 0.38.7
4
10
 
5
11
  ### Patch Changes
@@ -24,6 +24,8 @@ function annotateClickableElements(options = {}) {
24
24
  // Check if the element is not blocked and visible for clicking
25
25
  function isElementClickNotBlocked(element, windowToAnnotate) {
26
26
  const rect = element.getBoundingClientRect();
27
+ const originalScrollX = windowToAnnotate.scrollX;
28
+ const originalScrollY = windowToAnnotate.scrollY;
27
29
 
28
30
  // Calculate the center point of the element
29
31
  const centerX = rect.left + rect.width / 2;
@@ -56,7 +58,12 @@ function annotateClickableElements(options = {}) {
56
58
  const newCenterX = newRect.left + newRect.width / 2;
57
59
  const newCenterY = newRect.top + newRect.height / 2;
58
60
  const topElement = document.elementFromPoint(newCenterX, newCenterY);
59
- return element.contains(topElement);
61
+ const doesElementContainTopElement = element.contains(topElement);
62
+
63
+
64
+ // Restore the original scroll positions
65
+ windowToAnnotate.scrollTo(originalScrollX, originalScrollY);
66
+ return doesElementContainTopElement;
60
67
  }
61
68
 
62
69
  const topElement = windowToAnnotate.document.elementFromPoint(centerX, centerY);
@@ -369,7 +376,9 @@ function annotateClickableElements(options = {}) {
369
376
 
370
377
  // Filter for clickable elements
371
378
  const clickableElements = Array.from(windowToAnnotate.document.querySelectorAll("*")).filter((el) => {
372
- return isElementClickable(el) && isElementClickNotBlocked(el, windowToAnnotate);
379
+ const isClickable = isElementClickable(el);
380
+ const isClickNotBlocked = isElementClickNotBlocked(el, windowToAnnotate);
381
+ return isClickable && isClickNotBlocked;
373
382
  });
374
383
  // Generate hint strings for the clickable elements
375
384
  const hints = generateHintStrings(hintCharacterSet, Math.min(maxHints, clickableElements.length));
@@ -24,6 +24,8 @@ function annotateClickableElements(options = {}) {
24
24
  // Check if the element is not blocked and visible for clicking
25
25
  function isElementClickNotBlocked(element, windowToAnnotate) {
26
26
  const rect = element.getBoundingClientRect();
27
+ const originalScrollX = windowToAnnotate.scrollX;
28
+ const originalScrollY = windowToAnnotate.scrollY;
27
29
 
28
30
  // Calculate the center point of the element
29
31
  const centerX = rect.left + rect.width / 2;
@@ -56,7 +58,12 @@ function annotateClickableElements(options = {}) {
56
58
  const newCenterX = newRect.left + newRect.width / 2;
57
59
  const newCenterY = newRect.top + newRect.height / 2;
58
60
  const topElement = document.elementFromPoint(newCenterX, newCenterY);
59
- return element.contains(topElement);
61
+ const doesElementContainTopElement = element.contains(topElement);
62
+
63
+
64
+ // Restore the original scroll positions
65
+ windowToAnnotate.scrollTo(originalScrollX, originalScrollY);
66
+ return doesElementContainTopElement;
60
67
  }
61
68
 
62
69
  const topElement = windowToAnnotate.document.elementFromPoint(centerX, centerY);
@@ -369,7 +376,9 @@ function annotateClickableElements(options = {}) {
369
376
 
370
377
  // Filter for clickable elements
371
378
  const clickableElements = Array.from(windowToAnnotate.document.querySelectorAll("*")).filter((el) => {
372
- return isElementClickable(el) && isElementClickNotBlocked(el, windowToAnnotate);
379
+ const isClickable = isElementClickable(el);
380
+ const isClickNotBlocked = isElementClickNotBlocked(el, windowToAnnotate);
381
+ return isClickable && isClickNotBlocked;
373
382
  });
374
383
  // Generate hint strings for the clickable elements
375
384
  const hints = generateHintStrings(hintCharacterSet, Math.min(maxHints, clickableElements.length));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@empiricalrun/test-gen",
3
- "version": "0.38.7",
3
+ "version": "0.38.8",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org/",
6
6
  "access": "public"