Skip to content

fix(editor): ensure unique ID for ReadonlyEntry to prevent state rete…#1462

Open
prem22k wants to merge 2 commits intobpmn-io:developfrom
prem22k:fix/readonly-propagation
Open

fix(editor): ensure unique ID for ReadonlyEntry to prevent state rete…#1462
prem22k wants to merge 2 commits intobpmn-io:developfrom
prem22k:fix/readonly-propagation

Conversation

@prem22k
Copy link

@prem22k prem22k commented Feb 3, 2026

Closes #1461

Description:

Fixed a bug where the "Read only" property toggle would retain its state when switching between different form fields in the properties panel. This was caused by the ReadonlyEntry component reusing the same static ID 'readonly', which led to the underlying toggle component not being correctly re-initialized with the new field's value.

Changes:

  • Updated ReadonlyEntry.js to use a dynamic ID based on the field's ID (e.g., readonly-${field.id}). This forces the component to be re-created when the selection changes, ensuring correct state.

  • Updated GeneralGroup.spec.js to use the new namespaced IDs in tests to prevent regressions.

  • This PR adds a new form-js element or visually changes an existing component.

Copilot AI review requested due to automatic review settings February 3, 2026 10:30
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

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 fixes a bug where toggling the "Read only" property in Chrome would incorrectly retain its state when switching between different form fields. The issue was caused by the ReadonlyEntry component using a static ID, preventing proper component re-initialization when the selection changed.

Changes:

  • Updated ReadonlyEntry.js to use a dynamic ID based on the field's ID (readonly-${field.id})
  • Updated test expectations in GeneralGroup.spec.js to use the new namespaced IDs
  • Minor whitespace formatting changes in test helper functions

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
ReadonlyEntry.js Changed from static ID 'readonly' to dynamic ID readonly-${field.id} to force component re-creation on field selection changes
GeneralGroup.spec.js Updated test expectations to use 'readonly-undefined' to match the dynamic ID pattern when field.id is undefined, plus minor whitespace changes

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


// then
const readonlyInput = findInput('readonly', container);
const readonlyInput = findInput('readonly-undefined', container);
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

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

The test fields should include an id property to better reflect real-world usage and make the tests more robust. Currently, field.id is undefined in these tests, resulting in the ID readonly-undefined. Consider adding explicit field IDs (e.g., id: 'field1') to make the tests clearer and ensure they properly validate the dynamic ID generation.

Copilot uses AI. Check for mistakes.
Copy link
Author

Choose a reason for hiding this comment

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

@copilot open a new pull request to apply changes based on this feedback

Comment on lines 959 to 965

const { container } = renderGeneralGroup({ field, editField: editFieldSpy });

const readonlyInput = findTextbox('readonly', container);
const readonlyInput = findTextbox('readonly-undefined', container);
expect(readonlyInput.textContent).to.equal('foo');

// when
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

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

There is no test that specifically verifies the bug fix described in issue #1461. Consider adding a regression test that creates two fields with different IDs, sets readonly on the first field, switches to the second field, and verifies that the second field's readonly state is not affected. This would ensure the state retention issue doesn't reoccur.

Copilot uses AI. Check for mistakes.
Copy link
Author

Choose a reason for hiding this comment

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

@copilot open a new pull request to apply changes based on this feedback

…oups/GeneralGroup.spec.js

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@prem22k
Copy link
Author

prem22k commented Feb 5, 2026

@copilot open a new pull request to apply changes based on the comments in this thread

@vsgoulart vsgoulart self-requested a review February 6, 2026 00:13
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.

In chrome (maybe other browsers), toggling options seem to apply to the next selected element in a column as well

2 participants