Skip to content

Commit

Permalink
Backmerge: #2482 – Ketcher with iFrame loads with scrollbars activated (
Browse files Browse the repository at this point in the history
  • Loading branch information
Nitvex committed Apr 18, 2023
1 parent b844843 commit 7ad976c
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 16 deletions.
15 changes: 8 additions & 7 deletions packages/ketcher-core/src/application/render/raphaelRender.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ Render.prototype.update = function (
force = false,
viewSz = null,
options = {
extendCanvas: true
resizeCanvas: true
}
) {
// eslint-disable-line max-statements
Expand Down Expand Up @@ -232,16 +232,17 @@ Render.prototype.update = function (
const sz = cb.sz().floor()
const delta = this.oldCb.p0.sub(cb.p0).ceil()
this.oldBb = bb
// TO DO: decrease canvas size, when it has empty space. This logic needs to be defined in the future
if (
(!this.sz || sz.x > this.sz.x || sz.y > this.sz.y) &&
options.extendCanvas
) {
const shouldResizeCanvas =
(!this.sz || sz.x !== this.sz.x || sz.y !== this.sz.y) &&
options.resizeCanvas
if (shouldResizeCanvas) {
this.setPaperSize(sz)
}

this.options.offset = this.options.offset || new Vec2()
if ((delta.x !== 0 || delta.y !== 0) && options.extendCanvas) {
const shouldScrollCanvas =
(delta.x !== 0 || delta.y !== 0) && options.resizeCanvas
if (shouldScrollCanvas) {
this.setOffset(this.options.offset.add(delta))
this.ctab.translate(delta)
}
Expand Down
4 changes: 2 additions & 2 deletions packages/ketcher-react/src/script/editor/Editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ class Editor implements KetcherEditor {
this.render.ctab.setSelection(this._selection) // eslint-disable-line
this.event.selectionChange.dispatch(this._selection) // eslint-disable-line

this.render.update()
this.render.update(false, null, { resizeCanvas: false })
return this._selection // eslint-disable-line
}

Expand All @@ -380,7 +380,7 @@ class Editor implements KetcherEditor {
update(
action: Action | true,
ignoreHistory?: boolean,
options = { extendCanvas: true }
options = { resizeCanvas: true }
) {
if (action === true) {
this.render.update(true, null, options) // force
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export function dropAndMerge(
if (isMerging) editor.selection(null)

if (dropItemAction?.operations.length > 0) {
editor.update(dropItemAction)
editor.update(dropItemAction, false, { resizeCanvas: false })
}

return dropItemAction
Expand Down
2 changes: 1 addition & 1 deletion packages/ketcher-react/src/script/editor/tool/paste.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class PasteTool {
this.editor.render.page2obj(event)
)
this.action = action
this.editor.update(this.action, true, { extendCanvas: false })
this.editor.update(this.action, true, { resizeCanvas: false })

this.mergeItems = getMergeItems(this.editor, pasteItems)
this.editor.hover(getHoverToFuse(this.mergeItems))
Expand Down
6 changes: 3 additions & 3 deletions packages/ketcher-react/src/script/editor/tool/select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,8 @@ class SelectTool {
dragCtx.mergeItems = getMergeItems(editor, expSel)
editor.hover(getHoverToFuse(dragCtx.mergeItems))

extendCanvas(rnd, event)
editor.update(dragCtx.action, true, { extendCanvas: false })
resizeCanvas(rnd, event)
editor.update(dragCtx.action, true, { resizeCanvas: false })
return true
}

Expand Down Expand Up @@ -458,7 +458,7 @@ class SelectTool {
}
}

function extendCanvas(render, event) {
function resizeCanvas(render, event) {
const offset = 1
const {
isCloseToLeftEdgeOfCanvas,
Expand Down
4 changes: 2 additions & 2 deletions packages/ketcher-react/src/script/ui/component/form/input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type Props = {

export function GenericInput({
schema,
value = '',
value,
onChange,
innerRef,
type = 'text',
Expand All @@ -60,7 +60,7 @@ export function GenericInput({
<>
<input
type={type}
value={value}
value={value ?? ''}
onInput={onChange}
onChange={onChange}
className={clsx(classes.input, classes.genericInput)}
Expand Down

0 comments on commit 7ad976c

Please sign in to comment.