#5988 - Exception when modifying a functional group after adding a ketcher editor subscription #5993
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
How the feature works? / How did you fix the issue?
(Screenshots, videos, or GIFs, if applicable)
In issue #5988, the structure in the canvas disappeared when the editor was configured with a custom change subscription and a functional group was replaced with a different atom.
The error thrown is that the
_inverted
field on the s-group attribute operations are undefined, but assumed to be defined here:ketcher/packages/ketcher-react/src/script/editor/utils/customOnChangeHandler.ts
Line 46 in f873318
An operation's
_inverted
field is only set after theperform
function is executed here:ketcher/packages/ketcher-core/src/application/editor/operations/base.ts
Lines 41 to 48 in f873318
The change in this PR moves the
perform
function execution from before the s-group attribute operations were added to after, such that those operations also have their_inverted
field set.I tested the same behavior as in the issue locally and this change solves the issue:
https://github.com/user-attachments/assets/8b9764a3-1074-40de-a821-9e44cb16a9d9
Note that the
_inverted
field still can be undefined in thecustomOnChangeHandler
for other operations and this PR does not address that issue.Check list
#1234 – issue name