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

Use lodash throttle instead of debounce for updating selection change #3355

Merged
merged 3 commits into from
Feb 22, 2020

Conversation

thesunny
Copy link
Collaborator

Is this adding or improving a feature or fixing a bug?

Fixing a bug

What's the new behavior?

Switched slate to use lodash/throttle instead of debounce package for selection changes in slate.

How does this change work?

I just switched the method but the main change is the throttle will execute on the leading and trailing edge of the call while debounce only executed on the trailing edge. This means that the initial change was not reflected immediately causing some bugs when we grab the selection.

NOTE: I'm not experienced with typescript. I added @types/lodash package but am not sure if I did this properly, whether I grabbed the right version, or whether it's necessary at all.

Have you checked that...?

  • The new code matches the existing patterns and styles.
  • The tests pass with yarn test.
  • The linter passes with yarn lint. (Fix errors with yarn fix.)
  • The relevant examples still work. (Run examples with yarn start.)

Does this fix any issues or need any specific reviewers?

Fixes: #3338
Reviewers: @ianstormtaylor

@thesunny thesunny added the bug label Dec 19, 2019
@karelskopek
Copy link

@ianstormtaylor @thesunny Hey fellows! 🙌

Can we please merge this lovely PR? 🙏 We encountered the same issue rendering selection change highly unreliable (especially when using up and down arrows). 🙊

Or does it require further testing? 💯

@cameracker cameracker self-requested a review February 22, 2020 16:42
@cameracker
Copy link
Collaborator

Thanks @thesunny , I tested this locally and it appears to work well. Thanks for the fix!

@cameracker cameracker merged commit bd52b9d into ianstormtaylor:master Feb 22, 2020
thallada pushed a commit to considerhq/slate that referenced this pull request Feb 26, 2020
…ianstormtaylor#3355)

* Add lodash

* Switched debounce to lodash/throttle

* Updated yarn.lock
pzhine pushed a commit to databyss-org/slate that referenced this pull request May 17, 2020
…ianstormtaylor#3355)

* Add lodash

* Switched debounce to lodash/throttle

* Updated yarn.lock
lukesmurray pushed a commit to lukesmurray/slate that referenced this pull request Feb 5, 2021
…ianstormtaylor#3355)

* Add lodash

* Switched debounce to lodash/throttle

* Updated yarn.lock
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

editor.selection is delayed so selection is undependable to find current element
3 participants