Skip to content

Commit d874e53

Browse files
Merge pull request #702 from lukecotter/fix-optimised-timeline-search-trigger
fix: optimsed timeline has search triggered on tab switch
2 parents f24bc87 + 92c74ca commit d874e53

4 files changed

Lines changed: 40 additions & 6 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Added
1111

12-
-**Timeline**: A brand new **experimental** timeline Flame Chart that is up to **7X faster**. ([#446] [#251])
12+
-**Timeline**: A brand new **experimental** timeline Flame Chart that is up to **7X faster**. ([#446] [#251] [#92])
1313
- Enable it via **Settings -> Apex Log Analyzer -> Timeline -> Experimental -> Timeline**.
1414
- Generally Improved performance, especially for large logs.
1515
- Zoom and pan are now **7X faster**.
@@ -414,6 +414,7 @@ Skipped due to adopting odd numbering for pre releases and even number for relea
414414

415415
<!-- Unreleased -->
416416

417+
[#92]: https://github.com/certinia/debug-log-analyzer/issues/92
417418
[#694]: https://github.com/certinia/debug-log-analyzer/issues/694
418419
[#446]: https://github.com/certinia/debug-log-analyzer/issues/446
419420
[#251]: https://github.com/certinia/debug-log-analyzer/issues/251

log-viewer/src/features/timeline/optimised/ApexLogTimeline.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,12 +228,16 @@ export class ApexLogTimeline {
228228
*/
229229
private handleFind = (event: Event): void => {
230230
// Only process if this timeline instance is active
231-
if (!this.container || !this.container.isConnected) {
231+
if (!this.container || !this.container.isConnected || !this.container.clientHeight) {
232232
return;
233233
}
234234

235235
const customEvent = event as CustomEvent<FindEventDetail>;
236236
const { text, options } = customEvent.detail;
237+
if (!text) {
238+
this.handleFindClose();
239+
return;
240+
}
237241

238242
// Convert search text to predicate function (thin facade)
239243
const caseSensitive = options.matchCase;
@@ -293,6 +297,8 @@ export class ApexLogTimeline {
293297

294298
// Clear search state (FlameChart handles render)
295299
this.flamechart.clearSearch();
300+
301+
document.dispatchEvent(new CustomEvent('lv-find-results', { detail: { totalMatches: 0 } }));
296302
};
297303

298304
/**

log-viewer/src/features/timeline/optimised/FlameChart.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,11 @@ export class FlameChart<E extends EventNode = EventNode> {
593593
onClick: (x: number, y: number) => {
594594
this.handleClick(x, y);
595595
},
596+
onMouseLeave: () => {
597+
if (this.callbacks.onMouseMove) {
598+
this.callbacks.onMouseMove(0, 0, null, null);
599+
}
600+
},
596601
},
597602
);
598603
}

log-viewer/src/features/timeline/optimised/TimelineInteractionHandler.ts

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ export interface InteractionCallbacks {
4343

4444
/** Called when hover state over event changes. Returns true if over an event. */
4545
onHoverChange?: (isOverEvent: boolean) => void;
46+
47+
/** Called when mouse leaves the canvas. */
48+
onMouseLeave?: () => void;
4649
}
4750

4851
export class TimelineInteractionHandler {
@@ -124,8 +127,8 @@ export class TimelineInteractionHandler {
124127
const mouseUpHandler = this.handleMouseUp.bind(this);
125128

126129
this.canvas.addEventListener('mousedown', mouseDownHandler);
127-
document.addEventListener('mousemove', mouseMoveHandler);
128-
document.addEventListener('mouseup', mouseUpHandler);
130+
this.canvas.addEventListener('mousemove', mouseMoveHandler);
131+
this.canvas.addEventListener('mouseup', mouseUpHandler);
129132
this.registerBoundHandler('mousedown', mouseDownHandler);
130133
this.registerBoundHandler('mousemove', mouseMoveHandler);
131134
this.registerBoundHandler('mouseup', mouseUpHandler);
@@ -148,6 +151,11 @@ export class TimelineInteractionHandler {
148151
const clickHandler = this.handleClick.bind(this);
149152
this.canvas.addEventListener('click', clickHandler);
150153
this.registerBoundHandler('click', clickHandler);
154+
155+
// Mouse leave for hiding tooltips
156+
const mouseLeaveHandler = this.handleMouseLeave.bind(this);
157+
this.canvas.addEventListener('mouseleave', mouseLeaveHandler);
158+
this.registerBoundHandler('mouseleave', mouseLeaveHandler);
151159
}
152160

153161
/**
@@ -170,10 +178,10 @@ export class TimelineInteractionHandler {
170178
this.canvas.removeEventListener('mousedown', mouseDownHandler);
171179
}
172180
if (mouseMoveHandler) {
173-
document.removeEventListener('mousemove', mouseMoveHandler);
181+
this.canvas.removeEventListener('mousemove', mouseMoveHandler);
174182
}
175183
if (mouseUpHandler) {
176-
document.removeEventListener('mouseup', mouseUpHandler);
184+
this.canvas.removeEventListener('mouseup', mouseUpHandler);
177185
}
178186

179187
// Remove touch event listeners
@@ -197,6 +205,11 @@ export class TimelineInteractionHandler {
197205
this.canvas.removeEventListener('click', clickHandler);
198206
}
199207

208+
const mouseLeaveHandler = this.boundHandlers.get('mouseleave');
209+
if (mouseLeaveHandler) {
210+
this.canvas.removeEventListener('mouseleave', mouseLeaveHandler);
211+
}
212+
200213
this.boundHandlers.clear();
201214
}
202215

@@ -366,6 +379,15 @@ export class TimelineInteractionHandler {
366379
}
367380
}
368381

382+
/**
383+
* Handle mouse leave - notify when cursor exits canvas.
384+
*/
385+
private handleMouseLeave(_event: MouseEvent): void {
386+
if (this.callbacks.onMouseLeave) {
387+
this.callbacks.onMouseLeave();
388+
}
389+
}
390+
369391
// ============================================================================
370392
// TOUCH EVENT HANDLERS
371393
// ============================================================================

0 commit comments

Comments
 (0)