make Popper#update sync + make scheduleUpdate return promise
See original GitHub issueCodePen Demo
https://codepen.io/anon/pen/NwZQwK
What is the expected behavior?
In the CodePen, the popper should incorrectly be positioned if the update was sync. But because it’s not, the last transform line is what Popper knows about, not the first one.
Any other comments?
The asynchronous popper.update()
can cause some issues if the next line of code assumes the popper’s position has been updated. The onUpdate()
callback can’t really be used depending on the code structure.
I’ve been able to remedy this for a while with setTimeout()
defer calls (not sure if this is 100% reliable though), but it would be easier just to have a sync update method.
That, or update
is sync while scheduleUpdate
is async.
Is there a case where this wouldn’t be appropriate?
Issue Analytics
- State:
- Created 6 years ago
- Comments:27 (10 by maintainers)
Top Results From Across the Web
make Popper#update sync + make scheduleUpdate return ...
I think we can plan this change in the next major version, along with a promise-based API for scheduleUpdate .
Read more >react-popper: re-position using scheduleUpdate
When onDateRangeBtnClick is called after the button was clicked, I want to re-position the Popper element by calling scheduleUpdate method, but ...
Read more >Promise - JavaScript - MDN Web Docs
Creates a new Promise object. The constructor is primarily used to wrap functions that do not already support promises. Static methods. Promise.
Read more >Migration Guide | Popper
This named import lives under the Popper namespace object: ... is now forceUpdate() (and is sync); scheduleUpdate() is now update() (and returns a...
Read more >Sync, async, and promises | Cloud Functions for Firebase
Also, you can make sure that the Cloud Functions instance running your function ... When you return a JavaScript promise to a function,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hey @FezVrasta im writing a library that uses popper but I cannot assume that the environment my code runs in will support Promises. How do you feel about
scheduleUpdate
supporting both callbacks and Promises, similar to Vue’s $nextTick. The code could look like:Id be happy to submit a PR with this code and tests to along with it
Wow cool, good to know.
I think we can plan this change in the next major version, along with a promise-based API for
scheduleUpdate
.