Skip to content

Commit 8d0f6f9

Browse files
committed
Fix edge cases when hiding line graph previews
Switched hiding to be based on whether the time is within the visible range, which addresses an edge case when the sample is visible but is the last before the end of the range. This change also fixes an edge case where the selected time would be outside the visible range when unlocking the selection.
1 parent 54826ea commit 8d0f6f9

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/hub/SelectionImpl.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ export default class SelectionImpl implements Selection {
246246
unlock() {
247247
if (this.mode === SelectionMode.Locked) {
248248
let selectedTime = this.getSelectedTime();
249+
this.applyTimelineScroll(0, 0, 0);
249250
this.setMode(SelectionMode.Static);
250251
this.staticTime = selectedTime !== null ? selectedTime : 0;
251252
}

src/hub/controllers/LineGraphController.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,9 +348,15 @@ export default class LineGraphController implements TabController {
348348
filter: LineGraphFilter
349349
): string | null {
350350
if (!(key in commandCache)) return null;
351+
if (
352+
time < window.selection.getTimelineRange()[0] ||
353+
(time > window.selection.getTimelineRange()[1] && window.selection.getMode() !== SelectionMode.Locked)
354+
) {
355+
return null;
356+
}
351357
let command = commandCache[key];
352358
let index = command.timestamps.findLastIndex((sample) => sample <= time);
353-
if (index === -1 || (index >= command.values.length - 1 && window.selection.getMode() !== SelectionMode.Locked)) {
359+
if (index === -1) {
354360
return null;
355361
}
356362
let output = this.PREVIEW_FORMAT.format(command.values[index]);

0 commit comments

Comments
 (0)