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

Fix having tutorials update if text is deleted. #827

Merged
merged 3 commits into from
Jun 1, 2018

Conversation

manthey
Copy link
Contributor

@manthey manthey commented May 24, 2018

Tutorials should rerun whenever the contents change. Some code designed to perform updates when separate code blocks were edited happened to prevent deleting text from triggering the update.

@manthey manthey changed the title Fix having tutorials update if a text is deleted. Fix having tutorials update if text is deleted. May 25, 2018
Tutorials should rerun whenever the contents change.  Some code designed
to perform updates when separate code blocks were edited happened to
prevent deleting text from triggering the update.
@manthey manthey force-pushed the tutorial-update-on-delete branch from 8b24240 to 5f25375 Compare May 29, 2018 20:16
@@ -192,8 +192,8 @@ function process_block_debounce(selector, debounce) {
processBlockInfo.lastelem = selector;
if (!debounce) {
process_block(selector);
return;
}
Copy link
Member

Choose a reason for hiding this comment

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

@manthey could you explain why this change? Looking at the code it is not exactly clear to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When a text area is altered, we want to rerun the tutorial, but we want to debounce it so it doesn't rerun too often (to give you a chance to finish typing). We trigger this on textarea change, input, and propertychange events (and resetting a field). The specific bug that this fixes is when no editing has been done, and you click on a text area and just delete a character. In this case, because the area had not been the most recently altered, it enters this code path. However, since we are trying to debounce, instead of processing the block, it should fall through and set a timer to run after debouncing. But, the return was in the wrong place, and it never set the timer. If you clicked on another text area, or typed more, then this branch (from line 188) wasn't entered, and the tutorial would update. The return should only apply if we aren't debouncing and are processing the block immediately.

Copy link
Member

Choose a reason for hiding this comment

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

okay, thanks for the detailed explanation, it makes sense to me now.

  • aashish

@manthey manthey merged commit 8e790de into master Jun 1, 2018
@manthey manthey deleted the tutorial-update-on-delete branch June 1, 2018 19:05
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

Successfully merging this pull request may close these issues.

2 participants