Skip to content

ScrollBar resize can cause unintentional scroll #4192

@moniika

Description

@moniika

Describe the bug

The scrollbar resize call can unintentionally scroll.

To Reproduce

  1. Add 4 blocks with space between them and prepare a 5th block that would fit in empty space.
Blockly.Xml.domToWorkspace(
    Blockly.Xml.textToDom(
       '<xml xmlns="https://developers.google.com/blockly/xml">' +
       '<block type="controls_if" x="88" y="88"></block>' +
        '<block type="controls_if" x="288" y="88"></block>' +
        '<block type="controls_if" x="88" y="238"></block>' +
        '<block type="controls_if" x="288" y="238"></block>' +
        '</xml>'),
    workspace);
var xmlDom = Blockly.Xml.textToDom(
    '<xml xmlns="https://developers.google.com/blockly/xml">' +
    '<block type="controls_if" x="188" y="163"></block> +
    '</xml>');
  1. Set breakpoints at onScroll() call in Scrollbar.prototyle.resize and in WorkspaceSvg.setTopLevelWorkspaceMetrics_
  2. Add block in the middle of the existing blocks, should not trigger any scrolling.
Blockly.Xml.domToWorkspace(xmlDom, workspace);
  1. Step through breakpoints observing that hostmetrics.viewLeft is 0 in Scrollbar resize, but in setTopLevelWorkspaceMetrics_ this.scrollY is set to small but non-zero value, where we would expect zero.

Expected behavior

There shouldn't be scrolling.

Additional context

This can cause unwanted extra emission of viewport change events, once they are enabled.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions