MCPcopy
hub / github.com/CopilotKit/CopilotKit / show

Method show

packages/angular/src/lib/directives/tooltip.ts:185–231  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

183 }
184
185 private show(): void {
186 if (this.overlayRef) {
187 return;
188 }
189
190 // Create overlay
191 const positionStrategy = this.overlayPositionBuilder
192 .flexibleConnectedTo(this.elementRef)
193 .withPositions(this.getPositions())
194 .withPush(false);
195
196 this.overlayRef = this.overlay.create({
197 positionStrategy,
198 scrollStrategy: this.overlay.scrollStrategies.close(),
199 hasBackdrop: false,
200 });
201
202 // Create component portal and attach
203 const portal = new ComponentPortal(TooltipContent, this.viewContainerRef);
204 const componentRef = this.overlayRef.attach(portal);
205 componentRef.instance.text = this.tooltipText;
206
207 // Detect actual position after overlay is positioned
208 setTimeout(() => {
209 if (this.overlayRef && this.elementRef.nativeElement) {
210 const tooltipRect =
211 this.overlayRef.overlayElement.getBoundingClientRect();
212 const elementRect =
213 this.elementRef.nativeElement.getBoundingClientRect();
214
215 let actualPosition: "above" | "below" | "left" | "right" = "below";
216
217 // Determine actual position based on relative positions
218 if (tooltipRect.bottom <= elementRect.top) {
219 actualPosition = "above";
220 } else if (tooltipRect.top >= elementRect.bottom) {
221 actualPosition = "below";
222 } else if (tooltipRect.right <= elementRect.left) {
223 actualPosition = "left";
224 } else if (tooltipRect.left >= elementRect.right) {
225 actualPosition = "right";
226 }
227
228 componentRef.instance.position = actualPosition;
229 }
230 }, 0);
231 }
232
233 private hide(): void {
234 if (this.overlayRef) {

Callers 1

onMouseEnterMethod · 0.95

Calls 3

getPositionsMethod · 0.95
createMethod · 0.65
closeMethod · 0.65

Tested by

no test coverage detected