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

Feature request: Collapse/expand blocks on double click #2461

Closed
oboshto opened this issue May 14, 2019 · 1 comment
Closed

Feature request: Collapse/expand blocks on double click #2461

oboshto opened this issue May 14, 2019 · 1 comment

Comments

@oboshto
Copy link

oboshto commented May 14, 2019

Hey everyone! Some users of our platform requested collapsing blocks on double click. We've implemented it but it seems to be bugged.
Is it possible for you to implement this feature natively?

Our double click handler for blocks as a reference:

function setDblClickOnBlock (block, isChild) {
      if (!block) return
      let clickedCount = 0
      block.getSvgRoot().addEventListener('pointerdown', (e) => {
        clickedCount += 1

        // HACK: imitation of double-click
        if (clickedCount >= 2) {
          if (isChild) {
            e.stopPropagation()
          }
          block.setCollapsed(!block.isCollapsed())
        }

        setTimeout(() => {
          clickedCount = 0
        }, 300)
      })
}
@RoboErikG
Copy link
Contributor

If you want to make it work correctly you'll probably need to modify the BlockDragger (core/block_dragger.js), but because there are so many click targets on a block (icons & fields) it'll be difficult to get it right. Feel free to ask questions on the forum if you run into problems.

That being said, we don't plan to support this in the main library. We think this would be a confusing UX for most Blockly users and recommend adding an icon for collapsing/uncollapsing blocks for apps that need to collapse blocks frequently. Double click might be the right UX for your users, though.

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

No branches or pull requests

2 participants