Skip to content

Commit dee5d14

Browse files
Deselecting holes (#130)
* minimal working version of deselecting * stropPropagation for expected type, making it not trigger the onClick
1 parent e3a5600 commit dee5d14

4 files changed

Lines changed: 21 additions & 4 deletions

File tree

src/holesPanel/holesViewProvider.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ export class HolesViewProvider implements vscode.WebviewViewProvider {
101101
vscode.TextEditorRevealType.InCenter,
102102
);
103103
}
104+
this.webviewView?.webview.postMessage({
105+
command: 'highlightHole',
106+
holeId: hole.id,
107+
});
104108
}
105109
}
106110
});

src/holesPanel/webview/BindingsSection.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export const BindingsSection: React.FC<BindingsSectionProps> = ({
7474
const filteredCount = filteredBindings.length;
7575

7676
return (
77-
<div className="bindings-section">
77+
<div className="bindings-section" onClick={(e) => e.stopPropagation()}>
7878
<div
7979
className={`bindings-header${isActive ? '' : ' collapsed'}`}
8080
data-hole-id={holeId}

src/holesPanel/webview/HoleCard.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@ interface HoleCardProps {
66
hole: EffektHoleInfo;
77
highlighted: boolean;
88
onJump: (id: string) => void;
9+
onDeselect: () => void;
910
}
1011

1112
export const HoleCard: React.FC<HoleCardProps> = ({
1213
hole,
1314
highlighted,
1415
onJump,
16+
onDeselect,
1517
}) => {
1618
const cardRef = useRef<HTMLDivElement>(null);
1719

@@ -26,19 +28,25 @@ export const HoleCard: React.FC<HoleCardProps> = ({
2628
ref={cardRef}
2729
className={`hole-card${highlighted ? ' highlighted' : ''}`}
2830
id={`hole-${hole.id}`}
29-
onClick={highlighted ? undefined : () => onJump(hole.id)}
31+
onClick={() => {
32+
if (highlighted) {
33+
onDeselect();
34+
} else {
35+
onJump(hole.id);
36+
}
37+
}}
3038
>
3139
<div className="hole-header">
3240
<span className="hole-id">Hole: {hole.id}</span>
3341
</div>
3442
{hole.expectedType && (
35-
<div className="hole-field">
43+
<div className="hole-field" onClick={(e) => e.stopPropagation()}>
3644
<span className="field-label">Expected Type:</span>
3745
<span className="field-value">{hole.expectedType}</span>
3846
</div>
3947
)}
4048
{hole.innerType && (
41-
<div className="hole-field">
49+
<div className="hole-field" onClick={(e) => e.stopPropagation()}>
4250
<span className="field-label">Inner type:</span>
4351
<span className="field-value">{hole.innerType}</span>
4452
</div>

src/holesPanel/webview/HolesPanel.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ export const HolesPanel: React.FC<{ initShowHoles: boolean }> = ({
7373
vscode.postMessage({ command: 'jumpToHole', holeId: id });
7474
}, []);
7575

76+
const handleDeselect = useCallback(() => {
77+
setHighlightedHoleId(null);
78+
}, []);
79+
7680
return (
7781
<div className="holes-list">
7882
{!showHoles && <Warning />}
@@ -85,6 +89,7 @@ export const HolesPanel: React.FC<{ initShowHoles: boolean }> = ({
8589
hole={h}
8690
highlighted={h.id === highlightedHoleId}
8791
onJump={handleJump}
92+
onDeselect={handleDeselect}
8893
/>
8994
))
9095
)}

0 commit comments

Comments
 (0)