Skip to content

Conversation

@philippfromme
Copy link
Contributor

@philippfromme philippfromme commented Oct 21, 2025

Proposed Changes

This PR moves state like the selected element and the groups for the selected elements outside of the properties panel React component. This prevents stale selected elements like in #1131.

Checklist

To ensure you provided everything we need to look at your PR:

  • Brief textual description of the changes present
  • Visual demo attached
  • Steps to try out present, i.e. using the @bpmn-io/sr tool
  • Related issue linked via Closes {LINK_TO_ISSUE} or Related to {LINK_TO_ISSUE}

@bpmn-io-tasks bpmn-io-tasks bot added the in progress Currently worked on label Oct 21, 2025
@philippfromme philippfromme force-pushed the 1131-stale-element-fix branch from 992aedc to 6e4cd5c Compare October 22, 2025 12:41
@philippfromme philippfromme changed the title 1131 stale element fix Manage state outside of React Oct 22, 2025
@philippfromme philippfromme force-pushed the 1131-stale-element-fix branch from 6e4cd5c to 87c1e3f Compare October 22, 2025 13:11
@philippfromme philippfromme marked this pull request as ready for review October 22, 2025 13:29
@bpmn-io-tasks bpmn-io-tasks bot added needs review Review pending and removed in progress Currently worked on labels Oct 22, 2025
@philippfromme philippfromme requested a review from Copilot October 22, 2025 13:29
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors state management by moving selected element and group state outside of the React component into the BpmnPropertiesPanelRenderer class. This addresses issue #1131 by preventing stale selected elements through direct state management rather than React hooks.

Key Changes

  • Moved element selection and group calculation logic from BpmnPropertiesPanel React component to BpmnPropertiesPanelRenderer
  • Replaced React hooks (useState, useEffect, useMemo) with direct event listener patterns in the renderer
  • Updated provider constructors to initialize _injector before registering with the properties panel

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/render/BpmnPropertiesPanel.js Removed React state management hooks and event listeners; simplified to pure rendering component
src/render/BpmnPropertiesPanelRenderer.js Added state management for selected element and groups; implemented event listeners for updates
src/provider/bpmn/BpmnPropertiesProvider.js Reordered constructor to initialize _injector before registration
src/provider/camunda-platform/CamundaPlatformPropertiesProvider.js Reordered constructor to initialize _injector before registration
src/provider/zeebe/ZeebePropertiesProvider.js Reordered constructor to initialize _injector before registration
test/spec/BpmnPropertiesPanel.spec.js Updated tests to pass groups directly instead of using getProviders
test/spec/BpmnPropertiesPanelRenderer.spec.js Added comprehensive rendering tests for various state changes; wrapped existing test in describe block

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

});
};

const updateSelectedElement = () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find it a bit confusing that we define these methods inline. I will fix that.

@barmac
Copy link
Member

barmac commented Oct 24, 2025

To fix: label selection leads to an error

image

Comment on lines -72 to -75
// handle labels
if (newSelectedElement && newSelectedElement.type === 'label') {
newSelectedElement = newSelectedElement.labelTarget;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likely cause of the problem.

@barmac
Copy link
Member

barmac commented Oct 24, 2025

To fix: label selection leads to an error

image

Fixed via 8c91763

@philippfromme
Copy link
Contributor Author

Thanks for reviewing and fixing @barmac 🏅 Do you think the overall approach makes sense?

Comment on lines -1 to -6
import {
useState,
useMemo,
useEffect,
useCallback
} from '@bpmn-io/properties-panel/preact/hooks';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am super happy to see this removed.

@barmac
Copy link
Member

barmac commented Oct 24, 2025

Thanks for reviewing and fixing @barmac 🏅 Do you think the overall approach makes sense?

Absolutely! Great work

@barmac barmac merged commit 9cf9d4d into main Oct 24, 2025
9 checks passed
@barmac barmac deleted the 1131-stale-element-fix branch October 24, 2025 12:23
@bpmn-io-tasks bpmn-io-tasks bot removed the needs review Review pending label Oct 24, 2025
@philippfromme
Copy link
Contributor Author

@barmac I will go ahead and implement the same change in https://github.com/bpmn-io/dmn-js-properties-panel.

barmac added a commit to bpmn-io/dmn-js-properties-panel that referenced this pull request Oct 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants