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

Paste block in viewport / near cursor #6848

Closed
1 task done
BeksOmega opened this issue Feb 15, 2023 · 13 comments · Fixed by #7521, #7561 or #8173
Closed
1 task done

Paste block in viewport / near cursor #6848

BeksOmega opened this issue Feb 15, 2023 · 13 comments · Fixed by #7521, #7561 or #8173
Assignees
Labels
ghc-osd Reserved for open source day: https://anitab-org.github.io/open-source-day/ issue: bug Describes why the code or behaviour is wrong size: small Bugs that can be picked up and completed in 1-3 days

Comments

@BeksOmega
Copy link
Collaborator

BeksOmega commented Feb 15, 2023

🚧⚠️🚧 This issue is being saved for Grace Hopper Open Source Day. 🚧⚠️🚧 An event we're running to help girls and non-binary technologists make their first contributions to open source! Please see our list of help wanted issues if you'd like to contribute!


Check for duplicates

  • I have searched for similar issues before opening a new one.

Description

When you paste a block, you expect the block to appear in the part of the workspace you are looking at. Usually either:

  • In the middle of the view
  • Near where your cursor is

Currently in Blockly, this is ignored, and blocks are always pasted near the original block that was copied.

Reproduction steps

  1. Copy a block to the clipboard using ctrl + c.
  2. Scroll the workspace so that the original block is not in view.
  3. Paste the bloc using ctrl + v.
  4. Observe how the new pasted block is not in view, and was instead pasted near the original block.

Additional Info

Pasting in the viewport may cause cascading block bumps for the pasted blocks, which would also be a bad user experience. I'm nopt sure if this occures with the current system or not.

Note: block bumping is when we move blocks away from other blocks connections so they don't accidentally appear to be connected.

To Fix

  1. Follow the reproduction steps to reproduce the bug.
  2. Add a getRelativeToSurfaceXY(): Coordinate method to the IMovable interface.
  3. Modify the copy and cut callbacks to store the result of getRelativeToSurfaceXY in a copyCoords variable.
  4. Modify the paste callback to:
    A. Run copyWorkspace.getMetricsManager().getViewMetrics(true) to get the coordinates of the viewport of the workspace.
    B. If the copyCoords are within the viewport, pass copyCoords to clipboard.paste.
    C. Otherwise, paste at a new Coordinate in the middle of the viewport. You can use the view metrics to calculate this.
  5. Rerun the reproduction steps. This time if the original block is not in view, the block should be pasted in the middle of the viewport.⚠️
@BeksOmega BeksOmega added issue: bug Describes why the code or behaviour is wrong issue: triage Issues awaiting triage by a Blockly team member labels Feb 15, 2023
@koenvanwijk
Copy link
Contributor

As a user I copy a block, scroll to the place where I want to block to appear and paste. So scrolling to the default (duplicate) position will break my intent. I think pasting in the middle of my current view is ok as long as it will not connect to an existing stack at that place.

@maribethb maribethb removed the issue: triage Issues awaiting triage by a Blockly team member label Feb 22, 2023
@BeksOmega BeksOmega self-assigned this Aug 17, 2023
@BeksOmega BeksOmega added the issue: triage Issues awaiting triage by a Blockly team member label Aug 17, 2023
@BeksOmega BeksOmega removed their assignment Aug 17, 2023
@maribethb
Copy link
Contributor

This seems reasonable to add to core.

@maribethb maribethb removed the issue: triage Issues awaiting triage by a Blockly team member label Aug 23, 2023
@BeksOmega BeksOmega assigned BeksOmega and unassigned BeksOmega Aug 23, 2023
@BeksOmega BeksOmega added good first issue ghc-osd Reserved for open source day: https://anitab-org.github.io/open-source-day/ size: small Bugs that can be picked up and completed in 1-3 days labels Aug 29, 2023
@bsampada7
Copy link
Contributor

I would like to work on this issue

1 similar comment
@patelb268
Copy link

I would like to work on this issue

@BeksOmega
Copy link
Collaborator Author

@bsampada7 Go for it!

@patelb268 Happy to assign you to a different issue since @bsampada7 got here first =) Just comment on a different one and I'll get you assigned!

@Daphne-wu
Copy link

I would like to work on this issue

@BeksOmega
Copy link
Collaborator Author

Hiya @Daphne-wu Someone has already been assigned! If you coment on a different issue I'll get you assigned =)

@BeksOmega
Copy link
Collaborator Author

The code now relies on getSelected in the paste callback. Which means if you don't have a block selected when you paste, you get an error and pasting fails. This should be changed to not rely on getSelected.

@BeksOmega BeksOmega reopened this Sep 29, 2023
@BeksOmega BeksOmega self-assigned this Sep 29, 2023
@BeksOmega BeksOmega linked a pull request Sep 29, 2023 that will close this issue
1 task
@BeksOmega
Copy link
Collaborator Author

Marking this as triage re: #7521 (comment)

Looks like we might have had some conflicting changes and lost the fix from OSD.

@BeksOmega BeksOmega added the issue: triage Issues awaiting triage by a Blockly team member label Mar 29, 2024
@BeksOmega BeksOmega reopened this Mar 29, 2024
@bsampada7
Copy link
Contributor

Hi @BeksOmega , do I need to work on a fix for this? I'd be happy to work on it.

@BeksOmega
Copy link
Collaborator Author

Oh nope! You already wrote up a good fix, I think we just need to dig it out of the git history somewhere =) Thank you for your interest though! If you want to work on something else we have a list of other good first issues.

@maribethb maribethb removed issue: triage Issues awaiting triage by a Blockly team member good first issue labels Apr 3, 2024
@ggramlich
Copy link

@BeksOmega @maribethb Could you give an update about this?
It looks like there is an implementation which did not make it into the main branch and nobody is assigned to this issue any more.
It would be great, if the implementation could be integrated.

@BeksOmega BeksOmega added the issue: triage Issues awaiting triage by a Blockly team member label May 6, 2024
@maribethb maribethb removed the issue: triage Issues awaiting triage by a Blockly team member label May 10, 2024
@BeksOmega BeksOmega self-assigned this May 10, 2024
@BeksOmega BeksOmega assigned maribethb and unassigned BeksOmega May 14, 2024
@BeksOmega
Copy link
Collaborator Author

@maribethb Assigning this to you since you mentioned wanting it yesterday.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ghc-osd Reserved for open source day: https://anitab-org.github.io/open-source-day/ issue: bug Describes why the code or behaviour is wrong size: small Bugs that can be picked up and completed in 1-3 days
Projects
No open projects
Status: Done Coding
7 participants