8000 maxInstance fix by Apoorvgarg-creator · Pull Request #5430 · google/blockly · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

maxInstance fix #5430

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

Merged
merged 2 commits into from
Sep 9, 2021
Merged

maxInstance fix #5430

merged 2 commits into from
Sep 9, 2021

Conversation

Apoorvgarg-creator
Copy link
Contributor
@Apoorvgarg-creator Apoorvgarg-creator commented Sep 6, 2021

The basics

  • I branched from develop
  • My pull request is against develop
  • My code follows the style guide

The details

Resolves

Issue Fix #5374

Proposed Changes

This PR fixes the issue #5374, Filtering out the insertion marker in the function getsBlockByType will fix the issue.

Behavior Before Change

As @kvanthienen stated-
When the maxInstances option is set for a block (for example to 5), the corresponding block in the toolbox gets the 'blocklyDisabled' class after all the instances have been used in the workspace as expected.
The strange thing, however, is that this block already temporarily gets the 'blocklyDisabled' status while dragging around the second-last block on the workspace (for example block number 4). When the block is released, the status is flipped again.

Behavior After Change

This is a short term fix where blocks which are not real Insertion marker are filtered out. Hence, on dragging the block it is not counted twice.Thus solving the issue when Maxinstance is reached when the block haven't placed yet.

Screen.Recording.2021-09-06.at.8.55.53.AM.mov

Reason for Changes

Whenever we were picking a block set with a maxInstance, getsBlockByType returns the value with insertion marker + number of blocks, which was causing the problem as an virtual object (Insertion marker) got counted as well as.
So filtering out insertion marker gives the correct count.

Test Coverage

Tested on:

  • Desktop Chrome: Yes, Worked perfectly
  • Desktop Safari: Yes, Worked perfectly

Documentation

No changes in documentation

@BeksOmega

@Apoorvgarg-creator Apoorvgarg-creator requested a review from a team as a code owner September 6, 2021 03:56
@google-cla
Copy link
google-cla bot commented Sep 6, 2021

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@google-cla google-cla bot added the cla: no Used by Google's CLA checker. label Sep 6, 2021
@Apoorvgarg-creator
Copy link
Contributor Author

@googlebot I signed it!

@google-cla google-cla bot added cla: yes Used by Google's CLA checker. and removed cla: no Used by Google's CLA checker. labels Sep 6, 2021
@Apoorvgarg-creator Apoorvgarg-creator changed the title [WIP] maxInstance fix maxInstance fix Sep 6, 2021
@BeksOmega BeksOmega removed the request for review from cpcallen September 9, 2021 17:10
@BeksOmega BeksOmega self-assigned this Sep 9, 2021
@BeksOmega BeksOmega self-requested a review September 9, 2021 17:11
Copy link
Collaborator
@BeksOmega BeksOmega left a comment

Choose a reason for hiding this comment

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

Hi @Apoorvgarg-creator ! This fix looks great. Thank you for putting this PR up and filling out the description. Seeing what you did to test was really helpful for reviewing this PR =)

I left a comment with one little code simplification, but otherwise LGTM! Once that's fixed I'll get this merged.

Co-authored-by: Beka Westberg <bekawestberg@gmail.com>
@BeksOmega BeksOmega merged commit dfba007 into google:develop Sep 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Used by Google's CLA checker.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0