Skip to content

createInputFieldMountable loses #576

@vitalybe

Description

@vitalybe

Please fill out these Check-boxes

  • I checked for existing similar issues
  • I checked that the plugin is up to date
  • The issue persists with all other plugins and themes disabled

Plugin Version

v1.4.1

This Issue Occurs on

  • Windows
  • Linux
  • macOS
  • Android
  • iOS

Debug Info

SYSTEM INFO:
	Obsidian version: v1.8.10
	Installer version: v1.8.4
	Operating system: Darwin Kernel Version 24.4.0: Fri Apr 11 18:33:47 PDT 2025; root:xnu-11417.101.15~117/RELEASE_ARM64_T6000 24.4.0
	Login status: logged in
	Language: en
	Catalyst license: none
	Insider build toggle: off
	Live preview: on
	Base theme: adapt to system
	Community theme: none
	Snippets enabled: 0
	Restricted mode: off
	Plugins installed: 3
	Plugins enabled: 3
		1: Meta Bind v1.4.1
		2: JS Engine v0.3.2
		3: Dataview v0.5.68

RECOMMENDATIONS:
	Community plugins: for bugs, please first try updating all your plugins to latest. If still not fixed, please try to make the issue happen in the Sandbox Vault or disable community plugins.

Describe the Issue

When I use createInputFieldMountable function with a binding path that contains array index, e.g. data[1] the index is lost.

Steps to Reproduce

You can test it with the following markdown:

0 index:
\`\`\`js-engine
const mb = engine.getPlugin('obsidian-meta-bind-plugin').api;

const options = {
    declaration: {
        inputFieldType: "number",
        bindTarget: mb.createBindTarget('frontmatter', context.file.path, ['data', "0"])
    },
    renderChildType: "block"
};

const mountable = mb.createInputFieldMountable(context.file.path, options);
mb.wrapInMDRC(mountable, container, component);
\`\`\`

1 index
\`\`\`js-engine
const mb = engine.getPlugin('obsidian-meta-bind-plugin').api;

const options = {
    declaration: {
        inputFieldType: "number",
        bindTarget: mb.createBindTarget('frontmatter', context.file.path, ['data', "1"])
    },
    renderChildType: "block"
};

const mountable = mb.createInputFieldMountable(context.file.path, options);
mb.wrapInMDRC(mountable, container, component);
\`\`\`


0 index: `INPUT[number:data[0]]`
1 index: `INPUT[number:data[1]]`

Expected Behavior

Note that using the regular inputs at the bottom works fine but both of the inputs that were created with createInputFieldMountable act on the same property.

The issue seems to be coming from here:

fromExistingDeclaration(
		declaration: BindTargetDeclaration | undefined,
	): UnvalidatedBindTargetDeclaration | undefined {
		if (declaration === undefined) {
			return undefined;
		}
		return {
			storageType: toResultNode(declaration.storageType),
			storagePath: toResultNode(declaration.storagePath),
			storageProp: declaration.storageProp.path.map(x => ({
				type: x.type,
				prop: toResultNode(x.prop),
			})),
			listenToChildren: declaration.listenToChildren,
		};
	}

Since it discards the index property from the declaration

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugUndesired behavior caused by this plugin

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions