8000 fix: turn off button after inspecting (#202) · sveltejs/svelte-devtools@266c5e4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 266c5e4

Browse files
authored
fix: turn off button after inspecting (#202)
1 parent 463bdc6 commit 266c5e4

File tree

3 files changed

+6
-11
lines changed

3 files changed

+6
-11
lines changed

src/lib/runtime.svelte.ts

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ port.onMessage.addListener(({ type, payload }) => {
4747
case 'bridge::ext/inspect': {
4848
if (typeof payload === 'string') break;
4949
app.selected = app.nodes[payload.node.id];
50+
app.inspecting = false;
5051
break;
5152
}
5253

src/lib/state.svelte.ts

+2
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ export const app = $state({
3737

3838
selected: undefined as undefined | DebugNode,
3939
hovered: undefined as undefined | DebugNode,
40+
41+
inspecting: false,
4042
query: '',
4143
});
4244

src/routes/Inspector.svelte

+3-11
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,13 @@
22
import Button from '$lib/components/Button.svelte';
33
import { background } from '$lib/runtime.svelte';
44
import { app } from '$lib/state.svelte';
5-
6-
let active = $state(false);
7-
8-
$effect(() => {
9-
if (active && app.selected) {
10-
app.selected.dom?.scrollIntoView({ block: 'center' });
11-
}
12-
});
135
</script>
146

157
<Button
16-
{active}
8+
active={app.inspecting}
179
onclick={() => {
18-
active = !active;
19-
background.send('bridge::ext/inspect', active ? 'start' : 'stop');
10+
app.inspecting = !app.inspecting;
11+
background.send('bridge::ext/inspect', app.inspecting ? 'start' : 'stop');
2012
}}
2113
>
2214
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16">

0 commit comments

Comments
 (0)
0