@salesforcedevs/docs-components 1.17.6-hover-edit → 1.17.8-hover-edit

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforcedevs/docs-components",
3
- "version": "1.17.6-hover-edit",
3
+ "version": "1.17.8-hover-edit",
4
4
  "description": "Docs Lightning web components for DSC",
5
5
  "license": "MIT",
6
6
  "main": "index.js",
@@ -7,20 +7,19 @@
7
7
  min-width: 320px;
8
8
  max-width: 480px;
9
9
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
10
- position: relative;
10
+ position: fixed; /* Changed from relative to fixed for better positioning */
11
11
  overflow: hidden;
12
12
  opacity: 1;
13
13
  visibility: visible;
14
14
  transition: opacity 0.1s ease, visibility 0.1s ease;
15
+ z-index: 9999; /* Ensure it's above other content */
15
16
  }
16
17
 
17
18
  .text-selection-search-popover.hidden {
18
19
  opacity: 0;
19
20
  visibility: hidden;
20
21
  pointer-events: none;
21
- position: absolute;
22
- top: -9999px;
23
- left: -9999px;
22
+ /* Remove the absolute positioning that was causing issues */
24
23
  }
25
24
 
26
25
  /* Header Styles */
@@ -4,6 +4,7 @@
4
4
  <div
5
5
  class="text-selection-search-popover"
6
6
  class:hidden={isHidden}
7
+ style={popoverStyle}
7
8
  onkeydown={handleKeyDown}
8
9
  onclick={handlePopoverClick}
9
10
  >
@@ -21,24 +21,39 @@ export default class TextSelectionSearch extends LightningElement {
21
21
  private initialPopoverStyle: string = ""; // Store initial position
22
22
 
23
23
  connectedCallback() {
24
+ console.log('TextSelectionSearch: Component connected');
25
+ console.log('TextSelectionSearch: Document ready state:', document.readyState);
26
+ console.log('TextSelectionSearch: Current page URL:', window.location.href);
24
27
  this.setupTextSelectionListener();
25
28
  }
26
29
 
27
30
  disconnectedCallback() {
31
+ console.log('TextSelectionSearch: Component disconnected');
28
32
  this.removeTextSelectionListener();
29
33
  }
30
34
 
31
35
  // Setup text selection listener
32
36
  setupTextSelectionListener() {
33
37
  console.log('TextSelectionSearch: Setting up text selection listeners');
34
- document.addEventListener("mouseup", (event) => this.handleTextSelection(event));
35
- document.addEventListener("keyup", (event) => this.handleTextSelection(event));
38
+ try {
39
+ // Use capture phase to ensure we get the events
40
+ document.addEventListener("mouseup", (event) => this.handleTextSelection(event), true);
41
+ document.addEventListener("keyup", (event) => this.handleTextSelection(event), true);
42
+ console.log('TextSelectionSearch: Event listeners attached successfully');
43
+ } catch (error) {
44
+ console.error('TextSelectionSearch: Error setting up event listeners:', error);
45
+ }
36
46
  }
37
47
 
38
48
  removeTextSelectionListener() {
39
49
  console.log('TextSelectionSearch: Removing text selection listeners');
40
- document.removeEventListener("mouseup", (event) => this.handleTextSelection(event));
41
- document.removeEventListener("keyup", (event) => this.handleTextSelection(event));
50
+ try {
51
+ document.removeEventListener("mouseup", (event) => this.handleTextSelection(event), true);
52
+ document.removeEventListener("keyup", (event) => this.handleTextSelection(event), true);
53
+ console.log('TextSelectionSearch: Event listeners removed successfully');
54
+ } catch (error) {
55
+ console.error('TextSelectionSearch: Error removing event listeners:', error);
56
+ }
42
57
  }
43
58
 
44
59
  // Handle text selection
@@ -50,6 +65,8 @@ export default class TextSelectionSearch extends LightningElement {
50
65
  }
51
66
 
52
67
  console.log('TextSelectionSearch: Text selection event triggered');
68
+ console.log('TextSelectionSearch: Event type:', event?.type);
69
+ console.log('TextSelectionSearch: Event target:', event?.target);
53
70
 
54
71
  // Check if the event target is inside our popover
55
72
  if (event && event.target) {
@@ -62,6 +79,9 @@ export default class TextSelectionSearch extends LightningElement {
62
79
  }
63
80
 
64
81
  const selection = window.getSelection();
82
+ console.log('TextSelectionSearch: Selection object:', selection);
83
+ console.log('TextSelectionSearch: Selection string:', selection?.toString());
84
+ console.log('TextSelectionSearch: Selection range count:', selection?.rangeCount);
65
85
 
66
86
  if (!selection || selection.toString().trim() === "") {
67
87
  // Only hide popover if it's currently visible and we're not clicking inside it
@@ -94,16 +114,35 @@ export default class TextSelectionSearch extends LightningElement {
94
114
  const range = selection.getRangeAt(0);
95
115
  const rect = range.getBoundingClientRect();
96
116
 
97
- // Calculate popover position with more conservative positioning
98
- const popoverTop = this.popoverPosition === "top"
99
- ? Math.max(10, rect.top - 80) // Ensure it doesn't go off-screen
100
- : Math.min(window.innerHeight - 200, rect.bottom + 20);
117
+ console.log('TextSelectionSearch: Selection rect:', rect);
118
+ console.log('TextSelectionSearch: Window dimensions:', window.innerWidth, window.innerHeight);
119
+ console.log('TextSelectionSearch: Scroll position:', window.scrollX, window.scrollY);
120
+ console.log('TextSelectionSearch: Document height:', document.documentElement.scrollHeight);
101
121
 
102
- const popoverLeft = Math.max(10, Math.min(window.innerWidth - 350, rect.left + (rect.width / 2) - 175));
122
+ // Calculate popover position with better positioning logic
123
+ let popoverTop: number;
124
+ const popoverLeft = Math.max(10, Math.min(window.innerWidth - 360, rect.left + (rect.width / 2) - 180));
125
+
126
+ if (this.popoverPosition === "top") {
127
+ // Position above the selection
128
+ popoverTop = Math.max(10, rect.top - 200); // 200px above selection
129
+ } else {
130
+ // Position below the selection
131
+ popoverTop = Math.min(window.innerHeight - 250, rect.bottom + 20);
132
+ }
133
+
134
+ // Ensure the popover doesn't go off-screen
135
+ if (popoverTop < 10) {
136
+ popoverTop = 10;
137
+ }
138
+ if (popoverTop > window.innerHeight - 250) {
139
+ popoverTop = window.innerHeight - 250;
140
+ }
103
141
 
104
142
  this.popoverStyle = `position: fixed; top: ${popoverTop}px; left: ${popoverLeft}px; z-index: 9999; width: 350px;`;
105
143
  this.initialPopoverStyle = this.popoverStyle; // Store the initial position
106
144
  console.log('TextSelectionSearch: Popover style:', this.popoverStyle);
145
+ console.log('TextSelectionSearch: Calculated position - top:', popoverTop, 'left:', popoverLeft);
107
146
 
108
147
  this.isVisible = true;
109
148
  this.isHidden = false;
@@ -238,20 +277,4 @@ export default class TextSelectionSearch extends LightningElement {
238
277
  get searchButtonDisabled() {
239
278
  return this.isLoading || !this.searchQuery.trim();
240
279
  }
241
-
242
- renderedCallback() {
243
- if (this.isVisible && this.initialPopoverStyle) {
244
- const popover = this.template.querySelector('.text-selection-search-popover') as HTMLElement;
245
- if (popover) {
246
- // Always use the initial position, never recalculate
247
- popover.style.cssText = this.initialPopoverStyle;
248
- }
249
- } else if (!this.isVisible) {
250
- // Clear the style when popover is hidden
251
- const popover = this.template.querySelector('.text-selection-search-popover') as HTMLElement;
252
- if (popover) {
253
- popover.style.cssText = '';
254
- }
255
- }
256
- }
257
280
  }