Skip to content

Commit

Permalink
fix(devtools): unhighlight node after a short timer
Browse files Browse the repository at this point in the history
  • Loading branch information
logaretm committed Feb 23, 2025
1 parent 66d4b78 commit c6e1853
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/beige-eels-know.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@formwerk/devtools': patch
---

fix(devtools): Unhighlight node after a short timer
17 changes: 14 additions & 3 deletions packages/devtools/src/init.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { App, getCurrentInstance, nextTick, onMounted, onUnmounted, watch } from 'vue';
import { App, type ComponentInternalInstance, getCurrentInstance, nextTick, onMounted, onUnmounted, watch } from 'vue';
import { throttle } from 'packages/shared/src';
import { FormField, FormReturns } from '@core/index';
import { isSSR } from '@core/utils/common';
Expand Down Expand Up @@ -53,6 +53,17 @@ async function installDevtoolsPlugin(app: App) {
api => {
API = api;

async function highlight(vm: ComponentInternalInstance | null | undefined) {
if (!vm) {
return;
}

await api.highlightElement(vm);
setTimeout(() => {
api.unhighlightElement();
}, 1250);
}

api.addInspector({
id: INSPECTOR_ID,
icon: 'https://formwerk.dev/logo-w.svg',
Expand Down Expand Up @@ -138,7 +149,7 @@ async function installDevtoolsPlugin(app: App) {

if (form && '_vm' in form) {
SELECTED_NODE = { type: 'form', form };
api.highlightElement(form._vm);
highlight(form._vm);
}

return;
Expand All @@ -150,7 +161,7 @@ async function installDevtoolsPlugin(app: App) {

if (field) {
SELECTED_NODE = { type: 'field', field };
api.highlightElement(field._vm);
highlight(field._vm);
}

return;
Expand Down

0 comments on commit c6e1853

Please sign in to comment.