Skip to content

Commit 42a1ff7

Browse files
committed
Improves graph selection stability
1 parent 523975a commit 42a1ff7

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/webviews/apps/plus/graph/graph-wrapper/gl-graph.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ export class GlGraph extends LitElement {
204204

205205
private handleChangeSelection = debounce(
206206
(rows: GraphRow[]): void => void this.dispatchEvent(new CustomEvent('changeselection', { detail: rows })),
207-
250,
207+
50,
208208
{ edges: 'both' },
209209
);
210210

src/webviews/plus/graph/graphWebview.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1857,13 +1857,17 @@ export class GraphWebviewProvider implements WebviewProvider<State, State, Graph
18571857

18581858
private _fireSelectionChangedDebounced: Deferrable<GraphWebviewProvider['fireSelectionChanged']> | undefined =
18591859
undefined;
1860+
private _lastUserSelectionTime: number = 0;
18601861

18611862
private onSelectionChanged(e: UpdateSelectionParams) {
18621863
this._showActiveSelectionDetailsDebounced?.cancel();
18631864

18641865
const item = e.selection[0];
18651866
this.setSelectedRows(item?.id);
18661867

1868+
// Track when user explicitly selects
1869+
this._lastUserSelectionTime = Date.now();
1870+
18671871
this._fireSelectionChangedDebounced ??= debounce(this.fireSelectionChanged.bind(this), 50);
18681872
this._fireSelectionChangedDebounced(item?.id, item?.type);
18691873
}
@@ -2750,7 +2754,9 @@ export class GraphWebviewProvider implements WebviewProvider<State, State, Graph
27502754
const data = await dataPromise;
27512755
this.setGraph(data);
27522756

2753-
if (this._selectedId !== data.id) {
2757+
// Don't override selection if user selected something in the last 500ms
2758+
const userRecentlySelected = Date.now() - this._lastUserSelectionTime < 500;
2759+
if (!userRecentlySelected && this._selectedId !== data.id) {
27542760
selectionChanged = true;
27552761
this.setSelectedRows(data.id);
27562762
}

0 commit comments

Comments
 (0)