Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions src/api/tooltips/ToolTip.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ class Tooltip extends EventEmitter {
* @private
**/
show() {
const parentExists = this.tooltip && this.tooltip.parentElement &&
document.contains(this.tooltip.parentElement);
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable this.tooltip is undefined in the Tooltip class. The code attempts to access this.tooltip.parentElement, but this.tooltip is never initialized in the constructor.

The parentElement is passed to the constructor but only provided to the Vue component, not stored as an instance variable. To fix this, you should either:

  1. Store parentElement as this.parentElement in the constructor and check this.parentElement directly, or
  2. Store the entire options object as this.tooltip in the constructor

Suggested fix:

constructor({ toolTipText, toolTipLocation, parentElement, cssClasses } = { ... }) {
  super();
  this.parentElement = parentElement; // Add this line
  // ... rest of constructor
}

show() {
  const parentExists = this.parentElement && document.contains(this.parentElement);
  
  if (!parentExists) {
    console.warn('Tooltip parent does not exist anymore!');
    return;
  }
  // ... rest of method
}

Copilot uses AI. Check for mistakes.

if (!parentExists) {
console.warn('Tooltip parent does not exist anymore!');
return;
}
document.body.appendChild(this.component.$el);
this.isActive = true;
}
Expand Down
3 changes: 3 additions & 0 deletions src/api/tooltips/components/TooltipComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ export default {
inject: ['toolTipText', 'toolTipLocation', 'parentElement', 'cssClasses'],
computed: {
toolTipCoordinates() {
if (!this.parentElement || !document.contains(this.parentElement)) {
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method document.contains() is not a standard DOM API. To check if an element is in the document, you should use document.body.contains(this.parentElement) or document.documentElement.contains(this.parentElement) instead, which have better browser support.

Suggested fix:

if (!this.parentElement || !document.body.contains(this.parentElement)) {
  return { top: 0, left: 0, height: 0, width: 0 };
}
Suggested change
if (!this.parentElement || !document.contains(this.parentElement)) {
if (!this.parentElement || !document.body.contains(this.parentElement)) {

Copilot uses AI. Check for mistakes.
return { top: 0, left: 0, height: 0, width: 0 };
}
return this.parentElement.getBoundingClientRect();
},
toolTipLocationStyle() {
Expand Down
4 changes: 4 additions & 0 deletions src/api/tooltips/tooltipMixins.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ const tooltipHelpers = {
return;
}
let parentElement = this.$refs[elementRef];
if (!parentElement || !document.contains(parentElement)) {
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method document.contains() is not a standard DOM API. To check if an element is in the document, you should use document.body.contains(parentElement) or document.documentElement.contains(parentElement) instead, which have better browser support.

Suggested fix:

if (!parentElement || !document.body.contains(parentElement)) {
  console.warn('Cannot create tooltip: parent element does not exist');
  return;
}
Suggested change
if (!parentElement || !document.contains(parentElement)) {
if (!parentElement || !document.body.contains(parentElement)) {

Copilot uses AI. Check for mistakes.
console.warn('Cannot create tooltip: parent element does not exist');
return;
}
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new null check logic added to handle missing parent elements should be covered by tests. Consider adding test cases that verify the behavior when:

  1. parentElement is null
  2. parentElement is not in the document
  3. The tooltip is created successfully with a valid parent element

This would help ensure the null checks work as expected and prevent regressions. Other API modules in the codebase have corresponding Spec files (e.g., EditorSpec.js).

Copilot uses AI. Check for mistakes.
if (Array.isArray(parentElement)) {
parentElement = parentElement[0];
}
Expand Down
Loading