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

#5969 - Load from file having only micro structures on macro canvas causes unnecessary zoom up to 200% and shift molecule to top left angle #6057

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/ketcher-core/src/application/editor/Editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,8 @@ export class CoreEditor {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
window._ketcher_isAutozoomDisabled ||
!this.isCurrentModeWithAutozoom()
!this.isCurrentModeWithAutozoom() ||
!this.drawingEntitiesManager.hasMonomers
) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,16 @@ export class DrawingEntitiesManager {
return this.allEntities.length !== 0;
}

public get hasMonomers() {
const monomers = [...this.monomers.values()].filter(
Copy link
Collaborator

Choose a reason for hiding this comment

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

filter method doesn't mutate the original array and creates a new copy, perhaps you can just use this.monomers.values().filter() here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this.monomers.values() returns Iterator, so destructuring operator needs to create array from Iterator.

(monomer) =>
!monomer.monomerItem.props.isMicromoleculeFragment ||
isMonomerSgroupWithAttachmentPoints(monomer),
);

return monomers.length !== 0;
}

public get allBondsToMonomers() {
return [
...(this.polymerBonds as Map<number, PolymerBond>),
Expand Down
Loading