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
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tutorials/common/tutorials.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

return;
}
processBlockInfo.timer = window.setTimeout(function () {
process_block(processBlockInfo.lastelem);
Expand Down