-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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: fix SmoothScroll not applying custom options #11622
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With .bind()
, a new function will be created and attached to the event. So when we want to clear the handlers in _destroy
with this._handleLinkClick
, the function will not be detached from the event.
You could save this._handleLinkClick.bind(this)
as this._linkClickListenner
then reuse it in _destroy
to clear it.
@ncoden good catch! Fixed as suggested. Since |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thank you @ben-z 👍
Waiting for @DanielRuf to approve the changes as well. |
This pull request has been mentioned on Foundation Open Source Community. There might be relevant details there: https://foundation.discourse.group/t/foundation-for-sites-v6-6-0-is-here-farout/30/1 |
Description
SmoothScroll no longer takes into account the options passed in to its constructor because the event handler doesn't have the correct
this
. It worked prior to v6.5 because before the refactor, the event handler uses_this
from the closure instead ofthis
directly.Please refer to #11620 for a detailed description of this bug.
This PR binds
this
to the event handlers to solve the problem.Types of changes
Checklist
develop
ordevelop-v...
).It's my first time contributing. As far as I know there aren't any unit tests for this, so I didn't add any tests for my changes. Please let me know if I need to do anything else for this PR!