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

#5618 ketcher doesnt trigger change event in macromolecule mode #6012

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

Drimodaren
Copy link
Collaborator

How the feature works? / How did you fix the issue?

(Screenshots, videos, or GIFs, if applicable)

Check list

  • unit-tests written
  • e2e-tests written
  • documentation updated
  • PR name follows the pattern #1234 – issue name
  • branch name doesn't contain '#'
  • PR is linked with the issue
  • base branch (master or release/xx) is correct
  • task status changed to "Code review"
  • reviewers are notified about the pull request

@Drimodaren Drimodaren linked an issue Nov 26, 2024 that may be closed by this pull request
@Drimodaren Drimodaren changed the title 5618 ketcher doesnt trigger change event in macromolecule mode WIP #5618 ketcher doesnt trigger change event in macromolecule mode Nov 26, 2024
@Drimodaren
Copy link
Collaborator Author

image
image

@Drimodaren Drimodaren changed the title WIP #5618 ketcher doesnt trigger change event in macromolecule mode #5618 ketcher doesnt trigger change event in macromolecule mode Nov 26, 2024
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think this and many of the following screenshot updates are correct to be honest – there shouldn't be any structure duplication I guess

@@ -25,6 +26,7 @@ export class EditorHistory {
historyStack: Command[] | [] = [];
historyPointer = 0;
editor: CoreEditor | undefined;
ketcherInstance;
Copy link
Collaborator

Choose a reason for hiding this comment

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

As we discussed, you don't need this class property for now

} else {
this.event.change.dispatch(action);
ketcherProvider.getKetcher().changeEvent.dispatch(action);
Copy link
Collaborator

Choose a reason for hiding this comment

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

For a bit of readability I'd prefer to have some variable assigned to ketcher instance and it being reused as long as function uses ketcher more than once

@@ -40,7 +40,9 @@ type Data = {

export function customOnChangeHandler(action, handler) {
const data: Data[] = [];

if (!action) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's prepare this function a bit for some future adjustments. Let it be wrapper for both micro and macro 'changes' event handler and we will have two separate functions for micro and macro event handlers. The former will have all the existing functionality – preparing the data based on passed action and invoking the handler with this data. The latter will just have invoking the handler with empty arguments list – just what you've added here

Then, based on the currently active editor (you can use window.isPolymerEditorTurnedOn) just invoke either the first or the second function.

@@ -40,7 +40,9 @@ type Data = {

export function customOnChangeHandler(action, handler) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

For a fail safe check I'd add type for action parameter – let it be Action | undefined for now, as we could see, it's possible to trigger event without any data and it will silently fail on the following forEach call

Copy link
Collaborator

@svvald svvald left a comment

Choose a reason for hiding this comment

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

Changes are needed, disregard the previous approval

@@ -557,6 +557,7 @@ class Editor implements KetcherEditor {
}

undo() {
const ketcherProviderEditor = ketcherProvider.getKetcher().changeEvent;
Copy link
Collaborator

Choose a reason for hiding this comment

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

It is rather event instance than editor instance, I'd change variable name

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Maby ketcherChangeEvent?

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.

Ketcher doesn't trigger change event in macromolecule mode
3 participants