Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FormModeler Properties Panel Provider - useContext error when using an entry component #1369

Open
Revivius opened this issue Mar 4, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@Revivius
Copy link

Revivius commented Mar 4, 2025

Describe the Bug

Also posted in forum: https://forum.bpmn.io/t/formmodeler-properties-panel-provider-usecontext-error-when-using-an-entry-component/14461 ( Please let me know if this is considered cross posting / against the rules and I can remove it from the forum)

I am trying to implement a properties panel provider for the FormModeler.

I followed both custom components ( form-js-examples/custom-components at master · bpmn-io/form-js-examples) and custom button ( form-js-examples/custom-button at master · bpmn-io/form-js-examples) examples.

Setup of provider and linking it to FormModeler (via additionalModules) are all fine. I can modify groups and entries in them but having context (Preact related?) error when trying to re-use any entry component from @bpmn-io/properties-panel.

Uncaught TypeError: Cannot read properties of null (reading 'context')

at q2 (index.js:344:19)
at useError (useError.js:6:22)
at NumberFieldEntry (NumberField.js:117:23)
at x.component [as constructor] (DSFormPropertiesProvider.js:55:38)
at x.B [as render] (index.js:659:14)
at j (index.js:240:14)
at $ (children.js:96:16)
at j (index.js:262:13)
at $ (children.js:96:16)
at N (index.js:527:4)

Steps to Reproduce

Provider:

import { isNumberFieldEntryEdited, NumberFieldEntry } from '@bpmn-io/properties-panel';

export default class DSFormPropertiesProvider {

    // registraton is fine
    constructor(propertiesPanel) {
        propertiesPanel.registerProvider(this, LOW_PRIORITY);
    }

    getGroups(field, editField) {
        return (groups) => {
            // please see below for how group entries are created 
            groups.push(this.createMyCustomGroup(field, editField));

            return groups;
        };
    }

    createMyCustomGroup(field, editField) {
        // these functions are mostly copy paste from samples:
        const onChange = (key) => {
            return (value) => {
                const style = get(field, ['style'], {});
                editField(field, ['style'], set(style, [key], value));
            };
        };

        const getValue = (key) => {
            return () => {
                return get(field, ['style', key]);
            };
        };

        const debounce = (fn) => fn;

        return {
           id: 'style',
           label: 'Style',
           entries: [
               {
                   id: 'my-custom-property-id',
                   // I have context related error here
                   component: () => NumberFieldEntry({
                       debounce,
                       element: field,
                       getValue: getValue('min'),
                       id,
                       label: 'Minimum',
                       setValue: onChange('min')
                   }),
                   getValue,
                   field,
                   isEdited: isNumberFieldEntryEdited,
                   onChange
               }
           ]
      };
  }

  // inject panel
  DSFormPropertiesProvider.$inject = [
    "propertiesPanel"
  ];

Linking to FormModeler:

    ....
    new FormEditor({
        container: container,
        additionalModules: [
            DSFormPropertiesProvider // my provider
        ]
    });
   ....

Expected Behavior

Using entry components should work as in BPMN modeler. I implemented a custom properties panel provider for BPMN Modeler too and had no problem re-using eg TextFieldEntry the same way.

Environment

This is a React project with Vite tooling.

    "@bpmn-io/form-js": "^1.13.2",
    "@bpmn-io/properties-panel": "^3.25.1",
    "bpmn-js": "^18.1.2",
    "bpmn-js-properties-panel": "^5.30.0",
    "diagram-js-grid": "^1.1.0",
@Revivius Revivius added the bug Something isn't working label Mar 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant