@codemirror/autocomplete 0.19.8 → 0.19.9

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,3 +1,9 @@
1
+ ## 0.19.9 (2021-11-26)
2
+
3
+ ### Bug fixes
4
+
5
+ Fix an issue where info tooltips would be visible in an inappropriate position when there was no room to place them properly.
6
+
1
7
  ## 0.19.8 (2021-11-17)
2
8
 
3
9
  ### Bug fixes
package/dist/index.cjs CHANGED
@@ -484,9 +484,9 @@ class CompletionTooltip {
484
484
  if (!sel || !this.info)
485
485
  return null;
486
486
  let rect = this.dom.getBoundingClientRect(), infoRect = this.info.getBoundingClientRect();
487
- let top = Math.min(sel.getBoundingClientRect().top, innerHeight - infoRect.height) - rect.top;
488
- if (top < 0 || top > this.list.clientHeight - 10)
487
+ if (rect.top > innerHeight - 10 || rect.bottom < 10)
489
488
  return null;
489
+ let top = Math.max(0, Math.min(sel.getBoundingClientRect().top, innerHeight - infoRect.height)) - rect.top;
490
490
  let left = this.view.textDirection == view.Direction.RTL;
491
491
  let spaceLeft = rect.left, spaceRight = innerWidth - rect.right;
492
492
  if (left && spaceLeft < Math.min(infoRect.width, spaceRight))
@@ -496,10 +496,12 @@ class CompletionTooltip {
496
496
  return { top, left };
497
497
  }
498
498
  positionInfo(pos) {
499
- if (this.info && pos) {
500
- this.info.style.top = pos.top + "px";
501
- this.info.classList.toggle("cm-completionInfo-left", pos.left);
502
- this.info.classList.toggle("cm-completionInfo-right", !pos.left);
499
+ if (this.info) {
500
+ this.info.style.top = (pos ? pos.top : -1e6) + "px";
501
+ if (pos) {
502
+ this.info.classList.toggle("cm-completionInfo-left", pos.left);
503
+ this.info.classList.toggle("cm-completionInfo-right", !pos.left);
504
+ }
503
505
  }
504
506
  }
505
507
  createListBox(options, id, range) {
package/dist/index.js CHANGED
@@ -480,9 +480,9 @@ class CompletionTooltip {
480
480
  if (!sel || !this.info)
481
481
  return null;
482
482
  let rect = this.dom.getBoundingClientRect(), infoRect = this.info.getBoundingClientRect();
483
- let top = Math.min(sel.getBoundingClientRect().top, innerHeight - infoRect.height) - rect.top;
484
- if (top < 0 || top > this.list.clientHeight - 10)
483
+ if (rect.top > innerHeight - 10 || rect.bottom < 10)
485
484
  return null;
485
+ let top = Math.max(0, Math.min(sel.getBoundingClientRect().top, innerHeight - infoRect.height)) - rect.top;
486
486
  let left = this.view.textDirection == Direction.RTL;
487
487
  let spaceLeft = rect.left, spaceRight = innerWidth - rect.right;
488
488
  if (left && spaceLeft < Math.min(infoRect.width, spaceRight))
@@ -492,10 +492,12 @@ class CompletionTooltip {
492
492
  return { top, left };
493
493
  }
494
494
  positionInfo(pos) {
495
- if (this.info && pos) {
496
- this.info.style.top = pos.top + "px";
497
- this.info.classList.toggle("cm-completionInfo-left", pos.left);
498
- this.info.classList.toggle("cm-completionInfo-right", !pos.left);
495
+ if (this.info) {
496
+ this.info.style.top = (pos ? pos.top : -1e6) + "px";
497
+ if (pos) {
498
+ this.info.classList.toggle("cm-completionInfo-left", pos.left);
499
+ this.info.classList.toggle("cm-completionInfo-right", !pos.left);
500
+ }
499
501
  }
500
502
  }
501
503
  createListBox(options, id, range) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codemirror/autocomplete",
3
- "version": "0.19.8",
3
+ "version": "0.19.9",
4
4
  "description": "Autocompletion for the CodeMirror code editor",
5
5
  "scripts": {
6
6
  "test": "cm-runtests",