Skip to content

Commit

Permalink
fix: show uncontrolled field info in devtools closes #4914
Browse files Browse the repository at this point in the history
  • Loading branch information
logaretm committed Oct 27, 2024
1 parent f2972fc commit be994b4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/thick-sheep-drop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"vee-validate": patch
---

fix: show uncontrolled field info in devtools closes #4914
6 changes: 4 additions & 2 deletions packages/vee-validate/src/devtools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ function installDevtoolsPlugin(app: App) {
}

const { form, field, state, type } = decodeNodeId(payload.nodeId);
console.log(form, field, state, type, payload);

api.unhighlightElement();

Expand Down Expand Up @@ -203,6 +204,7 @@ export function registerSingleFieldWithDevtools(field: PrivateFieldContext) {

DEVTOOLS_FIELDS[field.id] = { ...field };
DEVTOOLS_FIELDS[field.id]._vm = vm;

onUnmounted(() => {
delete DEVTOOLS_FIELDS[field.id];
refreshInspector();
Expand Down Expand Up @@ -334,8 +336,8 @@ function getFieldNodeTags(

function encodeNodeId(form?: PrivateFormContext, stateOrField?: PathState | PrivateFieldContext): string {
const type = stateOrField ? ('path' in stateOrField ? 'pathState' : 'field') : 'form';
const fieldPath = stateOrField ? ('path' in stateOrField ? stateOrField?.path : unref(stateOrField?.name)) : '';
const idObject = { f: form?.formId, ff: fieldPath, type };
const fieldPath = stateOrField ? ('path' in stateOrField ? stateOrField?.path : toValue(stateOrField?.name)) : '';
const idObject = { f: form?.formId, ff: stateOrField?.id || fieldPath, type };

return btoa(encodeURIComponent(JSON.stringify(idObject)));
}
Expand Down

0 comments on commit be994b4

Please # to comment.